Question: In this exercise, you'll modify the while loop in the Guess the Number application so it doesn't use the break or continue statements. Open and
In this exercise, you'll modify the while loop in the Guess the Number application so it doesn't use the break or continue statements.
Open and run the project
Open the project named chexGuessNumber that's stored in the exstarts folder. Then, run the application to see how it works.
Remove the break statement
Modify the while loop so its Boolean expression checks that the guess and number variables aren't equal. To do that, you need to declare the guess variable outside the loop.
Move the statement that notifies the user of the correct guess so it executes after the while loop is finished.
Delete the else clause of the ifelse statement.
Move the code that increments the counter variable so it's only executed if the guess is too high or too low, not if the guess is the correct number.
Run the application and test it to make sure it still works correctly.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
