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
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