Project: Making change
Write a program that asks for a whole number of cents from 0 to 99 and works out the fewest coins needed to make that amount. When you run it, the output should match this format:
Please enter an amount between 0 and 99 cents.
87
Your change will be:
Q: 3
D: 1
N: 0
P: 2
The coins are:
- 1 quarter (Q) = 25 cents
- 1 dime (D) = 10 cents
- 1 nickel (N) = 5 cents
- 1 penny (P) = 1 cent
Hint: the mod operator (%) is useful here.
Save the file as coin_change.py.
Show a solution
Try the project on your own first. This is one working solution. Press Run, and a box asks for each input. Type the sample values from the project description to see the same output.
These tests check the solution above. They run a copy of the program, kept in PROGRAM, and give it pretend input. The testing tools here are not part of the course yet, so do not worry about how they work. Read the test names and the expected outputs: together they list what the program must do. Press Run to run the tests.
Projects run on your own computer, so you tell us when you are done.