Question: Write a JAVA program to simulate a coin flip. Ask user for number of times (n) coin must be flipped and display the number of
Write a JAVA program to simulate a coin flip. Ask user for number of times (n) coin must be flipped and display the number of heads and tails. You must allow the user to re-run the simulation until exit.
Hint: To simulate the coin flip, each time generate a random number between 0 and n. If the random number is divisible by 2, it is head else it is tail. Divisibility can be checked using the remainder (%) operator. If divisible, it will result in 0 else will result in 1.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
