I am trying to build a die roller, for a groupe of people, that says which of 5 people has gotten the 6. Right now the die roller tells how many rolls where made. I want it to tell which of the five persons (who roll out of turn) made the roll. So if the roll number (called i) is greater then 5 (number of players) we need to subtract 5 until it is. And then display which person made the roll and how many total rolls were made.
Code die roller:
i=0; % number of throws
while 1 i = i + 1; dieRoll = randi(6); % gives a random number 1-6
if dieRoll < 6; continue % continue if it's not a 6
else break % break if it is
end end disp(i) %display number of throws
I have then tried to implicate an other if else statement, but out of luck:
if i > 5 while i > 5 i=i-5; end else i=i end
Best Answer