ITEC 120 LAB 14 Back to Lab index page

Sam and Sue flip coins

You will write a driver program which uses the Coin class. Download Coin.java.

Write a driver which simulates this game between Sam and Sue: Sam and Sue each have a coin. They are going to flip their coins 100 times. For each toss, if both coins are the same, it's a tie. If the coins are different, heads wins.

Count how many wins Sam has, how many wins Sue has, and how many ties and print out these three numbers. Then congratulate the overall winner.

A sample run will look like this:

Out of 100 coin tosses,
Sam won 30 tosses.
Sue won 26 tosses, and
there were 44 ties.

Congratulations SAM!