Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using MATLab Problem 2 Write a program that implements a simple number guessing game. The script should first generate a random number with two significant

image text in transcribedusing MATLab

Problem 2 Write a program that implements a simple number guessing game. The script should first generate a random number with two significant decimal places that is in the range of -10 to 10 (use the functions rand() and round ( to do this). Next, the player must be given the chance to guess at the correct number, with their guess being rounded to two decimal places. If the user guesses a number greater than 10, their guess should be set to 10, whereas if they guess a number less than -10, their guess should be set to -10. After the player has made their guess, the program should indicate how close the guess is to being correct. The responses that the program should give are as follows: "You won if the exact correct number is guessed You were incredibly close if the guess is within 0.05 of the correct number You were very close if the guess is between 0.05 and 0.1 away from the correct number You were close if the guess is between 0.1 and 0.5 away from the correct number "You were kind of close if the guess is between 0.5 and 1 away from the correct number You were at least in the ballpark if the guess is between 1 and 2 away from the correct number "You were not close if the guess is between 2 and 5 away from the correct number "You were way off if the guess is further than 5 away from the correct number The program must allow the user to keep guessing until they eventually guess the correct number. This can be accomplished through the use of a while() loop

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions