Write a matlab script m-file to play a guessing game


Write a MATLAB script M-file to play a guessing game. The user will try to guess a number between 1 and 100. Your program will guide them to the right answer. Sample play should look like this:

Enter a number between 1 and 100 --> 50

Guess lower!

Enter your next guess --> 25

Guess higher!

Enter your next guess --> 33

Guess lower!

Enter your next guess --> 28

Congratulations! You got it in 4 guesses

Use the input command to obtain the guesses from the user. Note that you will be keeping track of how many guesses the user makes until the right answer is guessed.

This command generates a random number between 1 and 100: randi(100)

Optional improvements:

• Giving a special message for getting it on the first try.

• Giving a warning or error message if the user enters a number that is not between 1-100.

• Giving a warning or error message if the user does not enter a higher or lower number as instructed.

Request for Solution File

Ask an Expert for Answer!!
MATLAB Programming: Write a matlab script m-file to play a guessing game
Reference No:- TGS0733815

Expected delivery within 24 Hours