Question: #include Objective: Generate a coin dispenser machine. This machine would dispense change for any appropriate monetary value. This value should be less than $ 1
#include Objective: Generate a coin dispenser machine. This machine would
dispense change for any appropriate monetary value. This value should be
less than $ The machine uses an algorithm which dispenses the least
number of coins based on the US coin system of quarters, dimes, nickels,
and pennies.
As we talked about in class, $ worth of coins would be quarters
minimum number of coins
$ worth of coins would dispense quarters, dimes, pennies.
You can also use the Canadian coin system which includes dollar
cents and dollar coins, just indicate at the begin of your program which
monetary system youre referring to If you have any other monetary system
in mind, feel free to use it The algorithm would not change and only the coin
names and values would be modified.
Instructions: Write a program that would prompt the user to input some value
in dollars and cents in the format of $xxxx and solve the equivalent number
of coins. This number of coins can be at most $
For an input of $ the machine dispenses the following:
quarters
dime
nickel
pennies
points COP Assignment
Florida Atlantic University Sareh Taebi, PhD
Page of
To do this, you can first convert the input amount into cents:
$xxxx cents
Alternatively you can input $xxxx as a string using the string library. You
can then read each character and convert it back into a number like $
would be dissected as Each character can be converted back to
numeric value by subtracting it from like becomes number
You now have an integer number of pennies that need to be divided into
and single pennies. The coin designations are easily found by an
algorithm the uses the two operators for int division and for remaining
amount The algorithm is shown below:
$ is equivalent to cents.
First decide on the number of larger coins, quarters.
quarters
cents of change
Next, use the change to count the next largest coin, the dimes.
dime
cents of change
Use the change to count the nickels.
nickel
cents change
Finally, pennies are remaining, must be less than pennies.
pennies
cents left
The next step is displaying the original dollar amount along with the coin
designations and their number. The display should print something like
follows:
Value: $
Quarter:
Dime:
Nickel:
Penny:
Test your program on a variety of input values.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
