Write an application that will simulate a coin toss. Use the Math.random() funct
ID: 3930166 • Letter: W
Question
Write an application that will simulate a coin toss. Use the Math.random() function for the coin toss:
result = Math.random();
For the toss you may use the following criteria: if the result is 0.5 or less, the toss represents a head, otherwise it represents a tail.
Have a user input to determine how many tosses of the coin is desired. Generate the tosses and keep track of the number of heads and number of tails (do not display each toss). Display the percentage of heads and tails after the tosses are complete
Save the application as FlipCoin.java
Explanation / Answer
function flipCoin(){return Math.random()Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.