Question: Write a method called threeHeads that repeatedly flips a coin until the results of the coin toss are three heads in a row. You should
Write a method called threeHeads that repeatedly flips a coin until the results of the coin toss are three heads in a row. You should use a Random object to make it equally likely that a head or a tail will appear. Each time the coin is flipped, display H for heads or T for tails. When three heads in a row are flipped, the method should print a congratulatory message. Here is a possible output of a call to the method:
T T H T T T H T H T H H H
Three heads in a row!
Step by Step Solution
3.34 Rating (160 Votes )
There are 3 Steps involved in it
public static void threeHeads Random rand new Random int heads 0 while heads 3 int flip randnex... View full answer
Get step-by-step solutions from verified subject matter experts
