random names, yeap im bored  
Author Message
trs1800





PostPosted: 2004-2-12 10:18:00 Top

java-programmer, random names, yeap im bored /*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 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);
}


}
 
trs1800





PostPosted: 2004-2-12 12:56:00 Top

java-programmer >> 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);
}


}
 
Ryan Stewart





PostPosted: 2004-2-12 20:44:00 Top

java-programmer >> random names, yeap im bored "trs1800" <email***@***.com> wrote in message
news:RHDWb.8079$email***@***.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.


 
 
Ryan Stewart





PostPosted: 2004-2-12 21:00:00 Top

java-programmer >> random names, yeap im bored "Ryan Stewart" <email***@***.com> wrote in message
news:email***@***.com...
> "trs1800" <email***@***.com> wrote in message
> news:RHDWb.8079$email***@***.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);"


 
 
sgmanohar





PostPosted: 2004-2-13 1:14:00 Top

java-programmer >> random names, yeap im bored 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());
}
}
 
 
trs1800





PostPosted: 2004-2-13 5:51:00 Top

java-programmer >> random names, yeap im bored 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.
 
 
dacoty





PostPosted: 2004-2-17 1:51:00 Top

java-programmer >> random names, yeap im bored trs1800 <email***@***.com> wrote in message news:<nzSWb.7661$email***@***.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
 
 
gmcdanie





PostPosted: 2004-2-25 12:13:00 Top

java-programmer >> random names, yeap im bored
"david" <email***@***.com> wrote in message
news:email***@***.com...
> trs1800 <email***@***.com> wrote in message
news:<nzSWb.7661$email***@***.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.


 
 
sgmanohar





PostPosted: 2004-2-26 7:20:00 Top

java-programmer >> random names, yeap im bored > 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]