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

Part 1) Develop a program in which MatLab selects a random number between 1 and

ID: 3625314 • Letter: P

Question

Part 1) Develop a program in which MatLab selects a random number between 1 and
1000 (restrict the numbers to integers, no decimals!) and the user interacts with MatLab to try to guess the number. The program only ends when the user is able to correctly guess the number.

Part 2) Based on the strategy you used to try to discover MatLab’s number is Part 1,
develop a program in which the user selects a number between 1 and 1000 and MatLab
must try to guess the number. The program only ends when MatLab is able to correctly
guess the user’s number.

Rule: The interaction with MatLab in both cases cannot include numbers! Only questions
of the type “Is your number higher or lower than my last guess?” are allowed.

Explanation / Answer

% change line to

feed = input(‘Is your number higher or lower than my last guess? (type h or l) ’,'s');

if feed == 'h'