Question: Write a program called thinking.java , that is like the guessing game, I am thinking of a number between blank and blank. Use a Scanner

Write a program called thinking.java , that is like the guessing game, I am thinking of a number between blank and blank. Use a Scanner to prompt the user for the lower and upper bounds of the number theyre thinking of, and correct the error if y < x (i.e. swap the numbers). Use a binary search algorithm to iteratively guess what number they are thinking of. On each guess, prompt the user to see whether your guess is less than, greater than, or equal to their number. When the user responds that the guess was correct, print the number of guesses the program made and then exit. Example output: Think of a number! Lower bound: 1 Upper bound: 100 Is it 50? [lt/eq/gt]: lt Is it 25? [lt/eq/gt]: gt Is it 37? [lt/eq/gt]: eq It took 3 guesses to find the number 37!

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!