i got a question about random number..

this is my sample data :

jenny
jason
jerry
peter
chriss
wayne
ralf
andre
alexis
alex
garcia
lorris
ronny
lyn
armand

i wanna pick name above to put in free slot like below..

1..
2..
3..
4..
5..
6..
7..
-
-
-
140..

i wanna take all name to put within that number. and it need to be fair.. as example, if we got alex to fill first number, then we cant put him again for next 14 number.. but he can be place again starting from 16 and again from 31 until the slot already fill..

is there any way i can solve this?
thanks for helping

Recommended Answers

All 9 Replies

is there any way i can solve this?

Yes, you could solve that problem by writing a java program.

i got a question about random number

What is your question? Please be more specific that just stating the problem/assignment description.

ohh can u write sample code that can do that?
i just read about java.util.random but all the example given only can pick randomly but with repetitive..

all the example given only can pick randomly but with repetitive.

Can you explain what the problem is with using random?
What do you need random numbers for?

i need to pick that list of name to be place into that number(array) for creating fair duty for a staff at my place to work on the job given.. i need to pick it by random to make it fair

Please explain your problem with using the Random class to pick a name from the list of names.

the problem is eg: when first pick i got alex but for the 4th number i still got alex

Are you saying that you got the same random number two times in a row?
That is possible. For example when you flip a coin, it is random that it will be heads or tails. It can be heads two times in a row.
If you want to select all of the names in the list only one time for each, you need to use different logic. One way is to put the names in a List and use the Collections shuffle() method to randomize the List and then remove the names from that List one at a time.

ohh shuffle method, new for me..
can u show me a little sample with this data :

1,2,3,4,5

after i pick all for 1 time then i want to pick it for second round..

First you need to build a List with the data.
Then use the shuffle method.

Search for sample code both here and with Google

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.