Question
American money for amounts less than a dollar is composed of five coins: Half dollars, 50 cents Quarters, 25 cents Dimes, 10 cents Nickels, 5
Half dollars, 50 cents
Quarters, 25 cents
Dimes, 10 cents
Nickels, 5 cents
Pennies, 1 cent
Using these, we can make change for any amount less than a dollar. In fact, this system makes it easy to make change with the fewest coins possible, which isnt the case for all sets of coin amounts. To make change, you simply need to take as many of the largest coins as will fit into the amount, then do the same with each of the smaller coins. For example, to make change for 77 cents, we take one half dollar. This leaves 27 cents. We can then take one quarter, leaving 2 cents. We cannot take any dimes or nickels. We then take two pennies to complete the change.
Write a program to take input for the number of cents, then print out the number of each coin to make change using the fewest number of coins. For full points, your program should not use addition or subtraction (+ or - in Python); solutions that do use addition or subtraction will earn partial credit.
Code Submission Filename: change.py
Example Output:
Enter the number of cents: 93
1 half dollars
1 quarters
1 dimes
1 nickels
3 pennies
Enter the number of cents: 78
1 half dollars
1 quarters
0 dimes
0 nickels
3 pennies
Enter the number of cents: 15
0 half dollars
0 quarters
1 dimes
1 nickels
0 pennies
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