Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that plays the game of \"guess the number\" as follows: Your pro

ID: 2079978 • Letter: W

Question

Write a program that plays the game of "guess the number" as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000. When the program is ran the following should appear in the command window: I have a number between 1 and 1000. Can you guess my number? Please type your first guess: The player then enters the first guess. The program responds with one of the following responses: Excellent! You guessed the correct number! (and the program ends) Too Low. ! Enter new guess: Too high. ! Enter new guess: Requirements: Your program must contain a while loop. Your program will run until the number is guessed. The number your program selects as the number to be guessed should be obtained using matlab's randi function. Use help to determine how to use the function randi to generate an integer between 1 and 1000.

Explanation / Answer

clc
clear all
b= randi(1000); % random number
prompt='I have a number between 1 and 1000 Can you guess my number Please type your first guess:';
x=input(prompt)
while (true)
if x==b
'Excellent! You guessed the correct number!'
break
else if x<b
x=input( 'Too low. Try again! Enter new guess:')
else if x>b
x=input('Too high. Try again! Enter new guess:')
end
end
end
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote