473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

random names, yeap im bored

/*i think someone should use this to name their baby*/
import java.util.Random;
public class name
{
public static void main(String[] args)
{
String string1;
char char1 = 7;
string1 = " ";
int temp, length;
Random generator = new Random();
length = generator.nextInt(10);
for(int blah = 0;blah <= length;blah++)
{
temp = generator.nextInt(26);
if(temp == 1)
char1 = 65;
if(temp == 2)
char1 = 66;
if(temp == 3)
char1 = 67;
if(temp == 4)
char1 = 68;
if(temp == 5)
char1 = 69;
if(temp == 6)
char1 = 70;
if(temp == 7)
char1 = 71;
if(temp == 8)
char1 = 72;
if(temp == 9)
char1 = 73;
if(temp == 10)
char1 = 74;
if(temp == 11)
char1 = 75;
if(temp == 12)
char1 = 76;
if(temp == 13)
char1 = 77;
if(temp == 14)
char1 = 78;
if(temp == 15)
char1 = 79;
if(temp == 16)
char1 = 80;
if(temp == 17)
char1 = 81;
if(temp == 18)
char1 = 82;
if(temp == 19)
char1 = 83;
if(temp == 20)
char1 = 84;
if(temp == 21)
char1 = 85;
if(temp == 22)
char1 = 86;
if(temp == 23)
char1 = 87;
if(temp == 24)
char1 = 88;
if(temp == 25)
char1 = 89;
if(temp == 26)
char1 = 90;
string1 = string1 + char1;
}
System.out.println(string1);
}
}
Jul 17 '05 #1
7 3769
"trs1800" <no**@coo.ca> wrote in message
news:RH*****************@fe2.texas.rr.com...
/*i think someone should use this to name their baby*/
import java.util.Random;
public class name
{
public static void main(String[] args)
{
String string1;
char char1 = 7;
string1 = " ";
int temp, length;
Random generator = new Random();
length = generator.nextInt(10);
for(int blah = 0;blah <= length;blah++)
{
temp = generator.nextInt(26);
if(temp == 1)
char1 = 65;
if(temp == 2)
char1 = 66;
if(temp == 3)
char1 = 67;
if(temp == 4)
char1 = 68;
if(temp == 5)
char1 = 69;
if(temp == 6)
char1 = 70;
if(temp == 7)
char1 = 71;
if(temp == 8)
char1 = 72;
if(temp == 9)
char1 = 73;
if(temp == 10)
char1 = 74;
if(temp == 11)
char1 = 75;
if(temp == 12)
char1 = 76;
if(temp == 13)
char1 = 77;
if(temp == 14)
char1 = 78;
if(temp == 15)
char1 = 79;
if(temp == 16)
char1 = 80;
if(temp == 17)
char1 = 81;
if(temp == 18)
char1 = 82;
if(temp == 19)
char1 = 83;
if(temp == 20)
char1 = 84;
if(temp == 21)
char1 = 85;
if(temp == 22)
char1 = 86;
if(temp == 23)
char1 = 87;
if(temp == 24)
char1 = 88;
if(temp == 25)
char1 = 89;
if(temp == 26)
char1 = 90;
string1 = string1 + char1;
}
System.out.println(string1);
}
}


1) Your number, temp, will always be in the range 0-25, not 1-26. Either add
one before you go on, or better yet...

2) Instead of "if (temp == 1) ... if (temp == 2) ... blah blah blah string 1
= string 1 + char1;", how about "string1 = string1 + (temp + 65);"

3) This is more of a password generator. If you really want a name
generator, get a good name list, parse it, and pull names from it randomly.
There's some good ones out there. If you want size, look for a census
website.
Jul 17 '05 #2
"Ryan Stewart" <zz********@gSPAMo.com> wrote in message
news:xs********************@texas.net...
"trs1800" <no**@coo.ca> wrote in message
news:RH*****************@fe2.texas.rr.com...
/*i think someone should use this to name their baby*/
import java.util.Random;
public class name
{
public static void main(String[] args)
{
String string1;
char char1 = 7;
string1 = " ";
int temp, length;
Random generator = new Random();
length = generator.nextInt(10);
for(int blah = 0;blah <= length;blah++)
{
temp = generator.nextInt(26);
if(temp == 1)
char1 = 65;
if(temp == 2)
char1 = 66;
if(temp == 3)
char1 = 67;
if(temp == 4)
char1 = 68;
if(temp == 5)
char1 = 69;
if(temp == 6)
char1 = 70;
if(temp == 7)
char1 = 71;
if(temp == 8)
char1 = 72;
if(temp == 9)
char1 = 73;
if(temp == 10)
char1 = 74;
if(temp == 11)
char1 = 75;
if(temp == 12)
char1 = 76;
if(temp == 13)
char1 = 77;
if(temp == 14)
char1 = 78;
if(temp == 15)
char1 = 79;
if(temp == 16)
char1 = 80;
if(temp == 17)
char1 = 81;
if(temp == 18)
char1 = 82;
if(temp == 19)
char1 = 83;
if(temp == 20)
char1 = 84;
if(temp == 21)
char1 = 85;
if(temp == 22)
char1 = 86;
if(temp == 23)
char1 = 87;
if(temp == 24)
char1 = 88;
if(temp == 25)
char1 = 89;
if(temp == 26)
char1 = 90;
string1 = string1 + char1;
}
System.out.println(string1);
}
}
1) Your number, temp, will always be in the range 0-25, not 1-26. Either

add one before you go on, or better yet...

2) Instead of "if (temp == 1) ... if (temp == 2) ... blah blah blah string 1 = string 1 + char1;", how about "string1 = string1 + (temp + 65);"

3) This is more of a password generator. If you really want a name
generator, get a good name list, parse it, and pull names from it randomly. There's some good ones out there. If you want size, look for a census
website.


Correction on 2): "string1 = string1 + (char) (temp + 65);"
Jul 17 '05 #3
OR:

public class name{
public static void main(String[] args){
StringBuffer s = new StringBuffer();
int len=(int)(10*Math.random());
for(int i=0;i<len;i++) s.append((char)(65+Math.rand()*26+(i==0?0:32)));
System.out.println(s.toString());
}
}
Jul 17 '05 #4
S Manohar wrote:
OR:

public class name{
public static void main(String[] args){
StringBuffer s = new StringBuffer();
int len=(int)(10*Math.random());
for(int i=0;i<len;i++) s.append((char)(65+Math.rand()*26+(i==0?0:32)));
System.out.println(s.toString());
}
}

ah thanks both of you, i have only known java for about 15 days, im
still learning.
Jul 17 '05 #5
trs1800 <no**@coo.ca> wrote in message news:<nz****************@fe1.texas.rr.com>...
S Manohar wrote:
OR:

public class name{
public static void main(String[] args){
StringBuffer s = new StringBuffer();
int len=(int)(10*Math.random());
for(int i=0;i<len;i++) s.append((char)(65+Math.rand()*26+(i==0?0:32)));
System.out.println(s.toString());
}
}

ah thanks both of you, i have only known java for about 15 days, im
still learning.

i tried this code just for giggles and does not compile. i fixed it..
should look like this:
public class name{
public static void main(String[] args){
StringBuffer s = new StringBuffer();
int len=(int)(10*Math.random());
for(int i=0;i<len;i++)
s.append((char)(65+Math.random()*26+(i==0?0:32)));
System.out.println(s.toString());
}
}

it's the same code, but the line here:
for(int i=0;i<len;i++)
s.append((char)(65+Math.random()*26+(i==0?0:32)));

needed fixing from the previous post.. there is no Math.rand()
function, so just use Math.random() to get the same affect.
anyway, just wanted to post in case anyone else tried it and didnt
work.

take care --
David
Jul 17 '05 #6

"david" <da****@hotmail.com> wrote in message
news:22**************************@posting.google.c om...
trs1800 <no**@coo.ca> wrote in message

news:<nz****************@fe1.texas.rr.com>...
S Manohar wrote:
OR:

public class name{
public static void main(String[] args){
StringBuffer s = new StringBuffer();
int len=(int)(10*Math.random());
for(int i=0;i<len;i++) s.append((char)(65+Math.rand()*26+(i==0?0:32))); System.out.println(s.toString());
}
}

ah thanks both of you, i have only known java for about 15 days, im
still learning.

i tried this code just for giggles and does not compile. i fixed it..
should look like this:
public class name{
public static void main(String[] args){
StringBuffer s = new StringBuffer();
int len=(int)(10*Math.random());
for(int i=0;i<len;i++)
s.append((char)(65+Math.random()*26+(i==0?0:32)));
System.out.println(s.toString());
}
}


I think maybe I can name a pet Spacink, but I am not sure if I would name my
child.
Jul 17 '05 #7
> I think maybe I can name a pet Spacink, but I am not sure if I would name my
child.


Ah yes, pleasing the wife too is the hard thing. So how about this?

class name{
public static void main(String[]z){
String v="aeiou",p="cvccvc"; // or cvvcvc, cvcvcv
StringBuffer s=new StringBuffer();
char t;
for(int i=0;i<p.length();i++)
while((v.indexOf(t=(char)(97+Math.random()*26))>=0 ^ p.charAt(i)=='v')
|| s.append(t)==null);
System.out.println(s.toString());
}
}

PS thanks for the correction on rand[om]
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mali_djuro | last post by:
Hi all, i used JDOM to create XML file. first, i get data from database and create Document object. in some data i have quotas, so it makes replacment in content of elements. for example: if i...
0
by: trs1800 | last post by:
/*i think someone should you this to name their baby*/ import java.util.Random; public class name { public static void main(String args) { String string1; char char1 = 7; string1 = " "; int...
4
by: Frank & Janny Plaza | last post by:
I am trying to write a program in which the users will each enter their names and when all names have been entered, I want to randomly sort this list of names several times and then show the order in...
9
by: Bart Nessux | last post by:
I am using method 'a' below to pick 25 names from a pool of 225. A co-worker is using method 'b' by running it 25 times and throwing out the winning name (names are associated with numbers) after...
4
by: SoulSniper | last post by:
Hi, I have been stuck on this for a few days now and have given up trawling through pages and pages of google results.. I'm just putting the finishing touches to a small game I've written....
14
by: windandwaves | last post by:
Hi Folk I want a random list of numbers between 0 and 58 where each number can only occur once. I have written this ($f is an array): for($i = 0; $i < 13; $i++) { $rand =...
6
by: Mike Langworthy | last post by:
i can not seem to get this code to work. someone please help using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
5
by: LayneMitch via WebmasterKB.com | last post by:
Code is suppose to choose a random name using 'event listeners'. The reference file is a file downloaded from the book's publisher "Sitepoint". I doubt that there is anything wrong with the file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.