- #1
JohnPrior3
- 17
- 5
For Matlab, I need to write a program where a Gambler starts with 5 dollars and runs out with 1 dollar bets. The house has favorable odds of 70/30. I have gotten very far, but I can't find out how to end the loop when the gambler reaches 0. Here is my script:
My script runs the 100 times and leaves me with a negative number. Everything works for the script, except ending at 0. I tried doing a while loop but it didn't work.
Code:
A = 5
n=100;
x=rand(1,n);
for i=1:n-1
if x(i)>0.3
A=A-1
else
A=A+1
end
end
My script runs the 100 times and leaves me with a negative number. Everything works for the script, except ending at 0. I tried doing a while loop but it didn't work.
Last edited by a moderator: