# Random number

• 04-30-2013, 01:46 AM
Hawks
Random number
Thanks for all the help!
• 04-30-2013, 02:35 AM
leeroijenkiins
Re: Random number
i figure your new so atleast look this over...

Code:

```int total = 0, count = 0, r;                 Random randomGenerator = new Random();                                 do{                         r = randomGenerator.nextInt(11)+1;                         total = total + r;                         count++;                 }                 while(total <= 21);                 System.out.println(count);         }```
• 04-30-2013, 02:51 AM
Hawks
Re: Random number
Thank you so much, you are amazing!
• 04-30-2013, 07:21 AM
kjkrum
Re: Random number
Don't edit your posts like that. Now this post is of no value to anyone else.
• 04-30-2013, 07:37 AM
JosAH
Re: Random number
Here's the original content:

Quote:

-

How would I generate random numbers between 1-11 and when they total up to 21 or greater the systems tells me how many generated
numbers there were that added up to 21?

I have this so far, I think I am suppose to use RandomNumber command.

for (int i = 1; i < 11; i++)
kind regards,

Jos
• 04-30-2013, 07:05 PM
jim829
Re: Random number
OP aksed, "How would I generate random numbers between 1-11 and when they total up to 21 or greater the systems tells me how many generated
numbers there were that added up to 21?"

Hmm, what is the count when the first eight generated numbers are 4,8,3,2,4,9,10,1?

Regards,
Jim