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

Using MATLAB Problem #2: A friend of the family ask you to babysit their 4 year

ID: 3836615 • Letter: U

Question

Using MATLAB

Problem #2: A friend of the family ask you to babysit their 4 year old named Ahsoka. After the kid tablet run out of battery and is almost at the point to start screaming, you decide to play a game. Since you are an expert in MATLAB or at least love writing some easy scripts, you decide
to work a game for him. You want MATLAB to generate a random integer number that Ahsoka will guess.

Expected from this program:

• Generate a random integer (no higher than 25). Keep in mind that a 5 year old will probably do not want to play a game if it is too long or too short.

• Ask the user to input a guess. Please specify how high the guess could be.

• Check the guess given for the user. If the guess is too low tell the user: “Ahsoka, your guess is too low, please try again and enter a new guess number”. The same thing should happen if the guess is too high.

• When the guess is equal to the random number please congratulate Ahsoka.

• If you can add sounds to the game, Ahsoka will be more eager to play over and over again which will give you time to watch one episode of the Big Bang Theory. Plus you can get bonus points.

Example:
Please enter your guess between 1 and 20: 5

Sorry your guess is too low

Please enter your next guess: 15

Sorry your guess is too high

Please enter your next guess: 5

Sorry your guess is too low

Please enter your next guess: 10

Sorry your guess is too low

Please enter your next guess: 12

Sorry your guess is too low

Please enter your next guess: 14

Sorry your guess is too high

Please enter your next guess: 13 At last! :)

Explanation / Answer

%matlab code

number = randi(25);

while true
guess = input('Please eneter your guess between 1 and 25: ');
if guess > number
disp('Sorry your guess is too high');
elseif guess < number
disp('Sorry your guess is too low');
else
disp('At last! :)');
break
end
end

%{
output:

Please eneter your guoutputess between 1 and 25: 12
Sorry your guess is too low
Please eneter your guess between 1 and 25: 15
Sorry your guess is too low
Please eneter your guess between 1 and 25: 20
Sorry your guess is too high
Please eneter your guess between 1 and 25: 17
Sorry your guess is too high
Please eneter your guess between 1 and 25: 16
At last! :)
%}

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