Computers and Technology

Modify the guessing-game program so that the user thinks of a number that the computer must guess. The computer must make no more than the minimum number of guesses, and it must prevent the user from cheating by entering misleading hints.
Use I'm out of guesses, and you cheated and Hooray, I've got it in X tries as your final output.
(Hint: Use the math. log function to compute the minimum number of guesses needed after the lower and upper bounds are entered.)

Below are two test runs of the program:

Enter the smaller number: 0
Enter the larger number: 10

0 10
Your number is 5
Enter =, : : >
3 4
Your number is 3
Enter =, : =
Hooray, I've got it in 3 tries!
Enter the smaller number: 0
Enter the larger number: 50
0 50
Your number is 25
Enter =, : : : : : >
1 1
Your number is 1
Enter =, : >
I'm out of guesses, and you cheated!

The results you should get:

number is 3Hooray, I've got it in 3 tries

number is 11Hooray, I've got it in 5 tries

I'm out of guesses, and you cheated

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:00, jeffylovesgreenbeans
What computer network component allows data transfers from one computer to another through a telephone line?
Answers: 1
image
Computers and Technology, 22.06.2019 21:00, bryanatwin1536
Describir textbook icon_person mira los dibujos y describe lo que está pasando. usa los verbos de la lista.
Answers: 1
image
Computers and Technology, 24.06.2019 12:10, breezer20042
What is it called during the editing process when the processor ensures that a character holding a coffee mug from one angle is holding the same mug in the same way when the shot switches to another camera at another angle? cinematography continuity technology prop use
Answers: 1
image
Computers and Technology, 24.06.2019 13:00, giulissaf
Append and make table queries are called queries. select complex simple action i think action
Answers: 1
Do you know the correct answer?
Modify the guessing-game program so that the user thinks of a number that the computer must guess....

Questions in other subjects:

Konu
Mathematics, 28.06.2021 21:10