im in a java class and need to make a program that displays 6 random numbers between 1 and 49. ive gotten the display part to work... but the random generator confounds my logic. help PLEASE
random number generator
Collapse
X
-
One way to do this is by using the Random class within the java util package. The nextInt(int n) method will solve your problem (Returns an int value between 0 and the specified value(n) minus 1!). Of course you will need a loop too since you need 6 numbers.
Good luck :-) -
you can use nextInt(int) method of the java.util.Rando m class, found in java documentation. also u can find an example overthere.Originally posted by cwalsterim in a java class and need to make a program that displays 6 random numbers between 1 and 49. ive gotten the display part to work... but the random generator confounds my logic. help PLEASEComment
-
Hi,
just a word of advice, the nextInt(Number) begins at '0', so if you want to generate a number between 1-49 don't forget to add the '+1' after nextInt(Number) .
If you already didn't figure that one out.Comment
Comment