Making Change
Suppose a store's cash register stocks as many coins (pennies, nickels, dimes, quarters, fifty-cent pieces, and one-dollar coins) and as many bills (one-dollar, five dollar, ten dollar, and twenty dollar denominations) as possible.
Write a program that reads an amount of change (up to $200.00) and prints:
- all possible ways to make change, and
- the number of this alternatives.
Programming Notes
- Permutations of coins should be counted only once. That is, to make change for $0.11, four options should be counted: eleven pennies, six pennies and one nickel, one penny and two nickels, and one penny and one dime. The program should not count one penny and two nickels as being different from one nickel one penny and another nickel or as being different from two nickels and one penny.
- Use of one-dollar coin should be considered as being different from a one-dollar bill.
- The program should be reasonably efficient.
- To help save paper in testing, the program may have a command-line argument "print" or "no-print" that turns on or off the listing of all possible ways to make change. If this is implemented, "no-print" would indicate that the total number of ways to make change would be printed, but not the actual listing of all of those alternatives.
Hint: Although this problem can be solved in many ways, one reasonably efficient, simple, and elegant algorithm makes heavy use of recursion.
