76 978
Assignments Done
98,5%
Successfully Done
In June 2019

Answer to Question #4793 in MatLAB | Mathematica | MathCAD | Maple for Johnny

Question #4793
create a script guessing_game.m
computer generates a random integer between 1 and 20 inclusive
allow the user to guess 5 times or until the user gets the correct answer
count and display the number of guesses before a correct answer was made
stop if the user does not put in a value
display an appropriate message if the user wins or gives up
display a hint if the user gets the wrong value

script name guessing_game
intput variable: computer
input variable: guess

output variable: result
result = 0 if the user did not enter a value the loop exits (guess is an empty vector)
result = 1 if the user wins (matches the computer value)
result = 2 if the user loses (does not match after 5 guesses)

output variable: hint
hint = ‘low’ if the guess is low
hint = ‘high’ if the guess is high
output variable: count = number of guesses that the user makes including the winning guess
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions