Question: I am working on Debugging code for the number guessing game. I have already fixed all the other issues except for the issue that keeps

I am working on Debugging code for the number guessing game. I have already fixed all the other issues except for the issue that keeps outputting either too high or too low, regardless of the number. If the number is 5 and I enter 1, it will say too low, but if I enter 9 next it will still say too low, and vice versa for too high. Following is the code:

I am working on Debugging code for the number guessing game. I

have already fixed all the other issues except for the issue that

ch06 ex2_GuessingGame - NetBeans IDE 8.2 File Edit View Navigate Source Refactor Run Debug Profile Team Tools Window Help | Projects Debu... X Start Page Main.java NumberGame.java x ??'Attach Listener' inalizersusper "main' suspende D> Reference Hand D package murach.games: 3import java.util.Scanner; public class Main t ?? Signal Dispatche D public static void main (String args [) System.out.println("Welcome to the Number Guessing Game") System.out.println ) 10 Scanner sc- new Scanner (System. in); 12 13 14 15 16 17 18 19 20 21 System.out.print ("Enter upper 1imit for guess:") int upperLimit Integer.parseInt (sc.nextLine)); NumberGame game new NumberGame (upperLimit) System.out.println ) System.out.print ("Enter your guess: "); int guessInteger.parseInt (sc.nextLine O) while (guess != game. getNumber ( ) ) { if (guess game.getNumber )) System.out.println ("Your guess is too high.In") 26 27 28 game.incrementGuessCount ) System.out.print ("Enter your guess: "); Integer.parseInt (sc.nextLine )) 30 31 32 System.out.println ("Correct!n") System.out.println("You guessed the correct number in" + game.getGuessCount ) +"guesses.In") System.out.println("Bye!")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!