-
Help?...please?....
Guess a Number
This program generates a random integer between 1 and 100, including 1 and 100. It asks the user to guess the number. The user gets 10 guesses. After each guess, the program tells the user if the guess was too high or too low. If the user guesses within the 10 guesses, the user wins.
Sample run
Okay, I’ve got a number. What is your guess number 1?
50
Sorry, that’s too high.
What is your guess number 2?
25
Sorry, that’s too low.
What is your guess number 3?
42
Yes. That is the answer. You win!
COULD SOMEONE POSSIBLY TELL ME HOW I WOULD GO ABOUT DOING A WHILE LOOP FOR THE 10 GUESSES.
-
Code:
public class PseudoCode {
public static void main(String[] args) {
int count = 0;
boolean moreOfThis = true;
do {
// pick a random number
// ask user to guess
// check results
if(successful)
ask if they'll have another go
if(yes)
reset count
else
break; _or_ moreOfThis = false;
} while(moreOfThis);
}
}