Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Guess-My-Number Game Step 2 Objective: he purpose of this partof the project is to practice writing loops, particularly while loops. Requirement: Improve your Matlab program

image text in transcribedimage text in transcribed

Guess-My-Number Game Step 2 Objective: he purpose of this partof the project is to practice writing loops, particularly while loops. Requirement: Improve your Matlab program GMessNaumber an. After the improvement, your program can allow the user (i.e, the person who run the program) to try different guesses to approach and finally reach the randomly generated integer. For each guess, the program prints out a essage, as described in the instruction for step Based on the message, the user can make adjustment and then provide a guess closer to the integer. The program counts the number of guesses the user makes. When the user makes a guess matching the integer,the program shows the number of times the user has tried, as well as the integer Sample inputs and outputs: GuessNumber have a number between 1 and 1000. Guess what it is: 500 Too small Guess what it is: 730 Too small Guess what it is: 873 Close. Make it larger. Guess what it is: 925 close. Make it smaller. Guess what it is: 900 Close. Make larger. Guess what it is: 912 Very close now. Make it alittle bit larger. Guess what it is: 917 Very close now. Make it alittle bit smaller. Guess what it is: 915 Very close now. Make it alittle bit smaller. Guess what it is: 914. Yest You guessed the comect number in 9 shots. My number is 914. instruction Program The major is to put the main body of the program for step 1 into loop such that the user can different guesses. Specifically, you need to solve the following problems in the new program: What operations in the existing program for step I should be included in the loop? The operations need to be repeated basically include asking the user for an input, and 2) comparing the input with the integer and displaying the corresponding message. The code corresponding to these ions should be included inside the kop. 2. How control the loop, such that the loop terminates when the user makes a guess matching the integer? In your program, you can use a flag to denote whether the user has made a guess matching the integer or not. Thus, the program checks the flag to determine whether the kop should terminate or not. Specifically, the loop long as the flag is false, and the flag is setto when a guess maches the integer, How to count the number of guesses. You maintain counter in your program and increase the counter by I every time when the user makes The program skeleton is as follows. Note that some lines are pseudo-code and ellipses represent unfinished parts. You need to replace them with real code

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

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions