Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a number guessing program. You should think of a number between 1 and 100. Then, over and over again, the computer can suggest an

Write a number guessing program.

You should think of a number between 1 and 100. Then, over and over again, the computer can suggest an answer. If that answer is too small, you enter the character >. If the computer's answer is too large, you enter the character <. If the computer's answer is just right, you print "You win!"

First write a program to play this game once, until the computer wins. After that is working, write a program that plays the game over and over, each time with a different number. You can use the random number generator to generate the numbers. Count the number of guesses for each game, and print the average number of guesses.

There is a slow algorithm for finding the number, and a faster algorithm. The slow algorithm is acceptable, but the fast algorithm is much better. Use the fastest algorithm you can think of. I will give hints later if you ask for them.

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

More Books

Students also viewed these Databases questions