Exercise : 1.40. Instructions: Making change
Look inside the
exercises source folder and you will see assignments organized by name. Before continuing on to the next portion of the prep material, spend some time on the exercise.
It is not so important that you get the exercise exactly right. It is important to work through it as best you can before you look at the solution or continue with other work in this module.
You have some number of pennies, and you would like to determine how to make change for those pennies to obtain the proper number of each of the following currencies:
In making change, we seek the maximum number of each denomination in decreasing order. For example, given 798 pennies, your program should print the following:
For 798 pennies: 7 dollars 3 quarters 2 dimes 0 nickels 3 pennies
- Find and open the
ChangeJava program in the
exercises1package of the
- Add code as directed there to prompt the user to supply the number of pennies.
- Compute and print the output as suggested above.
- You need to use integer division and remainder (
%) to complete this exercise.
- Review the video materials as necessary for this module.