I am writing a program where the user enters a number and the computer guesses the number.
I'm having trouble with my else
/if
statement inside of my while
loop. The problem is it prints out "guess higher"
but the computer does not always guess higher. I'm not sure how to go about this problem.
while(computerGuess != userGuess) {
if(computerGuess > userGuess) {
System.out.println("Guess lower: ");
computerGuess = guess.nextInt(userGuess);
System.out.println(computerGuess);
}else if(computerGuess < userGuess) {
System.out.println("Guess higher: ");
computerGuess = guess.nextInt(101);
System.out.println(computerGuess);
}
amountTries++;
}