Can someone tell me, i'm trying to make the program choose a random number between 0 and 99 and the only way i know to call a random number is Math.random(); and that is for doubles between 0.0 and 1.0, so i'm not sure what to do. Help please?

david john, please use real words when posting to the forums. Abbreviations such as "U" in place of "you" only serve to make your posts more difficult to read and less likely to generate useful responses.

okay, so now i'm having another problem, i want the program to loop back to beginning if it doesn't guess the correct number. which would use a while statement right? i don't know what to put in the parenthesis for the while statement though..This is what i have:

Have you found the Random class, which has methods to supply (pseudo-)random integer numbers in a particular range?

Beware: if you want numbers between 0 and 99 you have to pass 100 as an argument.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 42573

31

posted

0

We prefer you to find out the solutions for yourself; you will find details about the while loop here, and you should find what they mean by "expression" here (I hope!)

john larry
Greenhorn

Joined: Nov 23, 2008
Posts: 9

posted

0

I'm doing this:

but i'm sure how to make the random number between a certain range, i can make it like between 0 and 100 or 0 and 50 or whatever, but what about like between 100 and 200, etc?

Let's say you know how to get random numbers between 0 and 100. What mathematical transformation could you apply to give you random numbers between 50 and 150? (Hint: you learned to do it when you were 5).

but i'm sure how to make the random number between a certain range, i can make it like between 0 and 100 or 0 and 50 or whatever, but what about like between 100 and 200, etc?

Think about it a bit.... If you have number between 0 and 100, how do you convert this number to a number between 100 and 200?