Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Description: Write a method named coinToss that simulates the tossing of a coin using the following method header: public static String coinToss ( )
Problem Description:
Write a method named coinToss that simulates the tossing of a coin using the
following method header:
public static String coinToss
When the method is called, it should generate a random number in the range
of through If the random number is the method returns a string "heads". If
the random number is it returns "tails".
You can use the random method of the Math class to generate a random
number between and like this:
random ;
Write a test program in the main method that asks the user how many times
the coin should be tossed and then simulates the tossing of the coin that number
of time using the method coinToss. It then displays a report as in the sample runs.
The program must then ask if the user wants to continue with another round of
coin tosses. If the user enters the program will start a new round. Otherwise, it'll
stop.
Sample run: red indicates user's inputs
How many times do you want to toss the coin?
How many times you want toss the coin?
Good bye!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started