Hello can anybody tell me why this code is not working? I copied it from this li
ID: 3698656 • Letter: H
Question
Hello
can anybody tell me why this code is not working?
I copied it from this link : http://www.chegg.com/homework-help/questions-and-answers/playing-game-roll-die-6-times-roll-5-6-four-times-win-4-dollars-two-three-times-win-2-doll-q20159331
Explanation / Answer
% function is not closed using end statement
% include "end" the end of code and then the code should work.
% matlab code
function prize = DiceGame(rolls)
winningRolls = 0;
for i = 1 : length(rolls)
if rolls(i) == 5 || rolls(i) == 6
winningRolls = winningRolls + 1;
end
end
if winningRolls >= 4
prize = 4;
elseif winningRolls > 1
prize = 2;
else
prize = 0;
end
% function is not closed using end in the code provided in screenshot
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.