Question: Create a java program to demonstrate this Coin class. In this program, instantiate four objects of the Coin class: one representing a quarter, one representing

Create a java program to demonstrate this Coin class.

In this program, instantiate four objects of the Coin class: one representing a quarter, one representing a dime, one representing a nickel, and one representing a penny. That is, the faceValue for them would be 25, 10, 5, and 1, respectively. After tossing the four coins, show the total by dollars. The total is calculated based on the face value of the coins landed heads-up. The program will ask the user whether he/she would like to toss again until the user chooses not to.

The output should look like this:

This program tosses four coins and get the total of values for coins landing on heads.

Ready to toss? (Y/N) y

The penny lands on Tails

The nickel lands on Tails

The dime lands on Tails

The quarter lands on Tails

The totla of the coin-tossing result is $0.0

Would yoiu like to toss again? (Y?N) yes

The penny lands on Heads

The nickel lands on Tails

The dime lands on Heads

The quarter lands on Tails

The total of the coin-tossing result is $0.11

Would you like to toss again? (Y?N) y

The penny lands on Tails

The nickel lands on Heads

The dime lands on Heads

The quarter lands on Tails

The total of the coin-tossing result is $0.15

Would you like to toss again (Y?N) n

Exit the program.

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!