Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Final Exam Part I ( 3 0 exam points ) Write a complete program to let the user play a guess a number between 1

Final Exam Part I (30 exam points)
Write a complete program to let the user play a "guess a number between 1 and 100" guessing game with the computer. If the user does not guess correctly
then the computer will update the boundaries using the last guess as one of the new boundaries.
When the user finally guesses the number, the computer should acknowledge this and also display the number of valid guesses that the user made. When the
user finally chooses not to play anymore, the program should print out a message with the best round played.
Below you will find an example run. Note that you must print out the correct answer each time before the user starts making guesses, so that I can verify
that the program is correctly winnowing down the search space. Failure to do so results in zero "functions correctly" points, and is guaranteed to drag some not-
insignificant number of design points with it.
Finally, this is officially part of your final exam. This is individual effortno help from anyone beyond the course instructor(s) and lab assistants. We will
answer clarifying questions, point to the general location of errors, etc, but little else.
Welcome to the Guessing Game!
(answer is 86)
Guess a number between 1 and 100: 42
Too low!
Guess a number between 42 and 100: 7
Your guess must be between 42 and 100.
Guess a number between 42 and 100: Bob
Your guess must be a number.
Guess a number between 42 and 100: 75
Too low!
Guess a number between 75 and 100: 90
Too high!
Guess a number between 75 and 90 : 83
Too low!
Guess a number between 83 and 90 : 86
You guessed it!
It only took you 5 guesses.
Play again? (Y/N): Y
(answer is 37)
Guess a number between 1 and 100: 50
Too high!
Guess a number between 1 and 50: 25
Too low!
Guess a number between 25 and 50: 37
You guessed it!
It only took you 3 guesses.
Play again? (YN
Thanks for playing!
Your best round was 3 guesses.
image text in transcribed

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

What would success look like to you?

Answered: 1 week ago

Question

(4) What do you do that creates obstacles in their way?

Answered: 1 week ago