Question: Hello, I have set up up my while loop, but I have a problem with 30 units one and part 2. if someone can help

 Hello, I have set up up my while loop, but I

have a problem with 30 units one and part 2. if someone Hello, I have set up up my while loop, but I have a problem with 30 units one and part 2. if someone can help me. Thank you !!

PartL Write a function called guessanumber in Matlab. The idea behind guessanumber is to have the user guess what number the computer is thinking of in no more than 10 attempts. The logical operation should be as follows: Every time guessanumber is called, the computer randomly picks an integer between 1 and 200, lets call this variable number. Guessanumber then prompts the user with the following message: "Guess a real number between 1 and 200:" let's call the user's response guess. If the user's guess is more than 30 units away from number, guessanumber should display the following message: "Sorry your guess is too far off (more than 30 units), try again... " If the user's guess is less than 30 units away from number, guessanumber informs the user that they should guess a bigger or a smaller number using one of the following appropriate prompts: "Good guess, you are within plus or minus 30 units of the number, but you need to guess a bigger number, try again... " OR "Good guess, you are within plus or minus 30 units of the number, but you need to guess a smaller number, try again... " If at any point the user guesses the right number, guessanumber should stop and display the following message: " You got it!! The number in mind is (display the number here)" If the user's guess is not correct, the code should display how many trials are left If the user has guessed 10 times and still hasn't guessed the right number guessanumber displays: If at any point the user guesses the right number, guessanumber should stop and display the following message: "You got it!!! The number in mind is (display the number here)" If the user's guess is not correct, the code should display how many trials are left. If the user has guessed 10 times and still hasn't guessed the right number guessanumber displays: "Sorry you are out of attempts! The number in mind was (display the number here) " Part II. Modify your code, so that incase the user inputs anything other than one integer, the code displays a message informing the user that their input is invalid, and they have wasted one of their 10 guesses. (hint: you could use function nargin)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!