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

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!