Create a new folder in your student folder on the T: drive named
HW4 and copy a blank Program.java
to the
HW4 folder.
To see how your homework should finally look run my version by
double clicking on My Computer and going to the folder
T:/Harcourt/Fall09/CS140/HW4
and then double
click on the file run.bat
.
Modify the Gamblers Ruin simulation we developed in class so that it prints a message every time the user tosses ten heads in a row or tosses ten tails in a row as well as the total number of heads, tails, and current account balance.
==
operator. For example
if (x == 10) { StdOut.println("X is ten!"); }
Enter initial investment: 10 Enter the number of times you want to toss the coin: 3000 We rolled 10 tails at roll 822 We rolled 10 tails at roll 2535 We rolled 10 heads at roll 2763 We rolled 10 tails at roll 2885 heads = 1478 tails = 1522 balance = -34