Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Multidimensional Array Data Management In Databases

Authors: Florin Rusu

1st Edition

1638281483, 978-1638281481

More Books

Students also viewed these Databases questions

Question

=+2. How reliable is this existing information?

Answered: 1 week ago