I need to create a program that randomly generates a number between 10 and 99 and i dont know how to do that. any ideas?
How do i generate a number between 10 and 99 in Java using the Random class?
import java.util.Random;
Random x = new Random();
x.nextInt(100) will generate a new random number between 0 and 100
add selection statement to reject numbers below 10.
alternatively use something like
randomno = x.nextInt(90) + 10;
neater and saves processing i guess
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment