I am writing a simple guessing game program where the user will input a number to try and guess a randomly generated number.
If they get the number right I want to
one issue :
Do not compare the content of two strings by == which just
you should use equals()
Imagine the right answer is one in this case
Follow this as your blue print sample
int answer = 0;
String yes = "";
Scanner input = new Scanner(System.in);
do{
do{
System.out.println("Enter your number");
answer = input.nextInt();
} while ( answer != 1);
System.out.println("Would you like to play again?");
yes = input.next();
} while ( yes.equalsIgnoreCase("yes"));
output:
