Question: Debug the Number Guessing Game Review the project 1. Open the project named ch06_ex2_GuessingGame in the extra_ex_starts directory. 1. Review the code and note that

Debug the Number Guessing Game

Review the project

1.

Open the project named ch06_ex2_GuessingGame in the extra_ex_starts directory.

1.

Review the code and note that NetBeans displays error icons for the compile time

errors.

Find and fix the compile-time errors

2.

Attempt to run the project. This should display an error message that contains links to

the errors.

3.

Find and fix these errors by clicking on the links to jump to the code for the error.

Sometimes the error marker in the left margin may not be on the same line as the actual

error.

4.

Find and fix any remaining compile- time errors. To do that, you can use the error icons

to locate the compile- time errors. Then, you can fix them.

Find and fix the runtime error

5.

Run the application to test it. Note that it

contains a runtime error. Specifically, the

game almost always tells you that your guess is is either too high or too low, no matter

which number you pick. For example, even if you chose 0, it might tell you that your

guess is too high.

6.

Use the NetBeans debugger to find and fix the bug that is causing this problem.

Hint: As you step through the code, keep an eye on the value of the guess variable.

I have gone through the first few steps ( up to 4) but when i get to step five I can find the problem.

Here is the code:

Debug the Number Guessing Game Review the project 1. Open the projectnamed ch06_ex2_GuessingGame in the extra_ex_starts directory. 1. Review the code and note

Thanks

Main.java NumberGame.java x Source History package murach.games: 3import java.util.Random; public class NumberGame f private int number: private int guessCount; public NumberGame (int upperLimit) 10 Random random = new Random(); number = randon.next Int (upperLimit + 1); guessCount 1; 12 13 15 16 17 18 19 20 21 public int getNumber) i return number; public int getGuessCount ) return guessCount: 23 public void incrementGuessCount () if guessCount = guessCount + 1; 25

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!