I am trying to create a questioner game using Matlab, but I have a small issue.
ID: 3863303 • Letter: I
Question
I am trying to create a questioner game using Matlab, but I have a small issue. My problem is that I want the game to stop if the number of wrong answers is two. However, I don't know how I can do it.
MATLAB R2016a academic use PLOTS EDITOR PUBLISH Insert Find Files compare 5 Go Too Comment New Open Save Breakpoints Pause Run and Advance Run and a print Find indent Re H: New folder (2) Editor HANew folder (2)Imain game.m Current Folder main game m x my score m x Tries m x Main game m x Name 1 1: 5: 6:10:11:15 Level ain game. main game asv main-game m correct answer" 0; myscore.m Wrong answer myscore1.m a 2 b 3 myscore2.m 100 mytotalscore.m while r w: 01 input enter a numbe Untitled,m 10 if 01. break end 13 end 14 while r w: wrong answer- wrong answer 1 15 choicel menu What is the capital city of Russia? Moscow Paris St. Petersburg 16 17 if choice correct answer correct answer 1 19 disp ('good' break 21 end Main game m (Function) 22 end. 23 Level II:51 e Tries (Number of tries) 24 while r w: 25 01 input enter a numbe if Q1 a; 26 27 break 28 29 end While r 31 Wrong answer Wrong answer 1 Search Documentation Ln 38 Col 08:52 T-IV/.F/IVExplanation / Answer
there is one bug in your program:
you are incrementing wrong answer before the user actually gives the ansewer,so to rectify it as well as to stop your program when wronganswer=2 do following changes in your code:
while r~=w
if(wronganswer>1)
return;% this shall terminate your script
end
choice1=menu("what is capital city of france?? moscow,paris,stpetersburg");
if(choice1==a)
correctanswer=correctanswer+1;
disp("good");
break;
end
wronganswer=wronganswer+1;
end
%note: do this change for all loops where you ask questions
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.