Question: You are given the main program and the output produced by it. You must write the Coin class, a file named Coin.java which will satisfy

You are given the main program and the output produced by it. You must write the Coin class, a file named Coin.java which will satisfy the class definition required by CoinTester.java. Be sure to write your Coin.java in the same directory with CoinTester.java.

Look at the main and see how the Coin class is constructed and what methods are called. From those observations, you can deduce the private data members and public methods with their exact naming and data type. Note that when a coin object is created, it's internal head and tail counts are initialized to zero. Each time a coin is .flip()'d that flip increments that coin's heads or tails counts with a 50% each probability. Thus, you must use a Random variable inside your Coin class to get a 50/50 chance of getting a head or tail. Once the flip method decided that a head or tail was rolled, the flip method increments the appropriate counter and then returns "H" or "T". The reset() method starts that coin's counters back at 0.

The main program can be seen below. The output is also show below in the command prompt.You are given the main program and the output produced by it.

FY18 Allocations Co FY18 Allocations Co FY18 Allocations. Con X C people.cs.pitt.edu/~hoffmant/S17-401/ CS 101 17 publio statio void tting aeg 8ysters print systees. printin ooin2.Elip Ngual ohanou of head. systers printin Equal printin Noti the tester progra rdcoded seed of 7 and the hich do ay get diff grading Desktop\ lab-ne-Ca CoinTeste lipping Coin 20 times TH THH lipping Coin2 10 times Ask me anything ectively. As off man) C chegg study IGuide x x Y GO ng a coin class fo x uld give the if yo utput every pt grad tests the wrote it 79% ing very old of the rectly yo 3:29 P 3/15/2017

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!