Question: Write a method called coinFlip that accepts a Scanner representing an input file of coin flips that are heads (H) or tails (T). Consider each

Write a method called coinFlip that accepts a Scanner representing an input file of coin flips that are heads (H) or tails (T). Consider each line to be a separate set of coin flips and output the number and percentage of heads in that line. If it is more than 50%, print “You win!”. Consider the following file:

H T H H T

T t    t    T h H

For the input above, your method should produce the following output:

3 heads (60.0%)

You win!

2 heads (33.3%)

Step by Step Solution

3.46 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static void coinFlip Scanner input while inputhasNextLine w Sc... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!