Question
Create a Guess the Number game in Matlab. Matlab will think of a random number between 1 and 50, and ask you to guess it.
Create a Guess the Number game in Matlab. Matlab will think of a random number between 1 and 50, and ask you to guess it. Matlab will tell you if each guess is too high or too low. You will win if you can guess the number within six tries. This game will use random numbers, loops, and input from the user. This is how the game should look like when executed (input in bold are from the user, doesnt need to be bold in Matlab):
Hello! What is your name? Joe
Well, Joe, I am thinking of a number between 1 and 50.
Take a guess.
10
Your guess is too high.
Take a guess.
2
Your guess is too low.
Take a guess. 4
Good job, Joe! You guessed my number in 3 guesses!
Or
Hello! What is your name? Zac
Well, Zac, I am thinking of a number between 1 and 50.
Take a guess. 50 Your guess is too high. Take a guess. 2 Your guess is too low. Take a guess. 45 Your guess is too high. Take a guess. 15 Your guess is too low. Take a guess. 40 Your guess is too high. Take a guess. 30 Your guess is too low. Take a guess. 38 Boo! You took 7 guesses to guess my number I win!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started