Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What is the full-cost budget?

Answered: 1 week ago