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
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment