|ITEC 120 LAB 11||Back to Lab index page|
Sam and Sue flip coins
You will write a driver program which uses the Coin class. Download Coin.java and put it in the same place as you put your lab11 java file.
Wrtie a driver which simulates this game between Sam and Sue: Sam and Sue each have a coin. They are going to flip their coins 20 times. If both coins are the same, it's a tie. If the coins are different, heads wins. Count the number of times sam wins, the number of times sue wins, and the number of ties. Report who is the overall winner.
A sample run will look like this:
4 tosses, and
Sam won 3 tosses.
There were 13 ties.
Another sample run:
5 tosses, and
Sam won 8 tosses.
There were 7 ties.
You will want to print out the value of each coin while you test your program to make sure your counts are correct. You can comment out those lines later.