473,321 Members | 1,748 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,321 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 3765
"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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.