Question: Write a C++ program that inputs the number of cents (you can assume it is an integer between 0 and 99) and outputs the number
Write a C++ program that inputs the number of cents (you can assume it is an integer between 0 and 99) and outputs the number of quarters, dimes, nickels and pennies that add up to the inputted amount and minimizes the number of coins needed.
Example:
- If the input was 76, we would expect an output of: 3 quarters, 0 dimes, 0 nickels, 1 pennies.
- If the input was 39, we would expect an output of: 1 quarters, 1 dimes, 0 nickels, 4 pennies.
Hints:
- As usual, it is important to think about how you would do this BEFORE you start programming.
- Ask yourself "how would I do this if I was at a register?"
- All the variables should be integers. This allows you to do integer division.
- The modulo (%) operator will be useful.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
