help with creating a guessing game
Hello. I am working on a homework assignment for my intro java class. The program should generate a random number from 1 to 20, and prompt the user for a guess. If the user guesses wrong, the program prompts the user again for the same number (no new random number). The program should keep asking the user until he/she gets it right.
Once the user guesses the right number, the program should display "You won! The number of guesses was ___". Guesses outside the range of 1-20 do not count.
I keep trying to make this program work but i am struggling hard. for starters, is this how you generate a random number?
[CODE]Random rGen = new Random();
rNum = rGen.nextInt(20) + 1;[CODE]