(Matlab) need to modify the code: Player fails the game if you cannot make it wi
ID: 3916316 • Letter: #
Question
(Matlab) need to modify the code: Player fails the game if you cannot make it within 3 tries. Player can do this game up to 10 times. If player input is larger than 10, it will display “Dumb” and immediately stop the game.
%-----------------------------------------------------------
while(1)
count=0;
guess=input('Guess a number between 0 to 10 ');
if(R>guess)
disp('Your guess is too small')
elseif (R<guess)
disp('Your guess is too large')
elseif (R==guess)
disp('You are correct! It is '); guess
R=floor( rand()*10 );
end
count=count+1;
if(count==3)
break;
end
end
Explanation / Answer
while(1) count=0; guess=input('Guess a number between 0 to 10 '); if guess < 0 || guess > 10 disp('Dumb') break; end if(R>guess) disp('Your guess is too small') elseif (RRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.