% Clean Up
% Close the opened figures and clear all variables
clear all;
close all;
% Open a dialog box asking the user 1 to put a number
secretnumber=str2double(inputdlg('Enter your secret number','secretnumber'));
%Open a dialog box asking the user 2 to put a number
number1=str2double(inputdlg('Enter your guess','number1'));
%If on the first try he got it right
if number1==secretnumber msgbox('good game 1 try')
end
%If the number1>secretnumber show a msgbox saying it
while number1~=secretnumber
% 1st time
if number1>secretnumber
uiwait(msgbox('Your guess is higher than the secret number, try again','modal'));
str2double(inputdlg('Enter your guess','number1'));
end
if number1<secretnumber
uiwait(msgbox('Your guess is lower than the secret number, try again','modal'));
str2double(inputdlg('Enter your guess','number1'));
end
end
I got until here; i don't know how to continue until 15th time, i tried to put msgbox ('you got the number after 1 try') after the last 'if' function in the loop , but whatever number i will put it will show the message box with the text inside so, what should i do to contiue until 15th times ?
Thanks a lot.