Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP! Greetings Professor Falken. Do you want to play a game? You, the user will 'think of a number between 1 and 100 both

PLEASE HELP!

image text in transcribed
"Greetings Professor Falken." "Do you want to play a game?" You, the user will 'think" of a number between 1 and 100 both inclusive ('inclusive' means that 1 and 100 are also valid values for input). The computer is going to try to guess what the number is that you are thinking of. To accomplish this, you will write a program that will take as the isput, the number you are thinking of. The program you will write will output a series of guesses, until the correct number is found. BUT! The program you will write will not be just a series of random guesses. Instead. you will write an 'intelligent program' that will guess the number you are thinking of in as few tries as possible. The program will prompt for the number you are thinking of, and the computer will display its guesses. The program will output the computer's current guess and will output if the current number is less than or higher than the number the user was thinking. The program will be written so that the computer guesses are half way of each iteration. The computer will always start with guessing 50 (half way between 1 and 100). Note: When you calculate the number that is half-way, please use the int () function to truncare any decimal values. Using ot functions like round, floor, ceil will produce incorrect output and you will loose marks accordingly. If 50 is not the correct answer, then the computer will look half way between (based on if the number that the user was thinking of w higher or lower than the current guess by the computer.). If the number the user was thinking of is higher than 50, then the computer will add half of the original value (50 divided by 2 is 25) the current guess of 50 and the new current guess by the computer will be 75 (50 plus 25 is 75). If the number the user was thinking of is lower than 50, then the computer will subtract half of the original value (50 divided by 2 is 25 to the current guess of 50 and the new current guess by the computer will be 25 (50,minus 25 is 25). This will repeat until the computer correctly guesses the number the that the user was originally thinking of. You can assume that the user will always enter a valid input number so you don't have to worry about checking the validity of the inputs. Here are some examples of the expected output

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions