Question
Coin.java The Coin class must be the enum class, defining the instances HEADS and TAILS . CoinTossing.java The CoinTossing class should be a simple class
Coin.java
The Coin class must be the enum class, defining the instances HEADS and TAILS.
CoinTossing.java
The CoinTossing class should be a simple class (with a main method) that uses the values provided by a Coin class, and performs a simulation of the tossing of a coin.
There must be a separate (possibly static) flip method that takes no arguments and returns a value of the Coin class. The result returned from the flip method is the random result from the flipping of a coin. You may choose which class of which this method is to be a member.
Write the CoinTossing class so that it may do as many tosses as the user requests at each iteration. The user inputs an integral value saying how many additional tosses are to be performed each time (say, something like 1000000), and the program counts how many times each side of the coin appears. The program continues looping asking the user for additional tosss until the user enters 0, indicating that the user wishes no more tosses of the coin. At this point, the program terminates.
After each entry from the user, output the total cumulative count (adding up the total from the start of the execution of the program) of each of the possible outcomes, so that it may be determined whether the simulated coin appears to be fair (i.e., has approximately as many HEADS as TAILS). [The program will be tested by asking for something like one million tosses, then about another million to see what the result looks like after a total of near two million tosses, and so on.]
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