1999 LSU Computer Science High School Programming Contest
Novice Problem 8
Can you spare a dime?

The Icy Cold Cola Company has many cola machines scattered throughout Petticoat Junction. These are all new machines that accept coins, dollar bills and five dollar bills. Unfortunately, the original programmer who wrote the code for returning change was very lazy. His algorithm always returns change in nickels (imagine buying the small Icy Cold Cola bottle for fifteen cents and getting $4.85 change in nickels). Since the introduction of the new cola machine, sales have plumetted. A survey discovered that customers did not like carrying around a lot of change (because of the weight).

The Icy Cold Cola Company has hired you to write a new change making program. The program must calculate how to make change so that the customer gets the correct amount of change with the least amount of weight (after all, the customers were upset about the weight of the coins). You also may not give more than fifteen of a single coin in change.

The Icy Cold Cola Company sells drinks for $0.15, $0.55, $0.95 and $1.15. You will be given two values: the amount of the sale and the amount of money the customer deposited (will not exceed $5.00). You stop making change when the amount of the sale is -1. All amounts will be given in pennies. You are allowed to make change in nickels, dimes, and quarters. Nickels weigh 0.18 ounces. Dimes weigh 0.1 ounces. Quarters weigh .27 ounces.

Sample Input Data:

15 
75
115 
500
55  
100
-1

Sample Output:

60 cents as 6 dimes
385 cents as 11 quarters    11 dimes
45 cents as 1 quarters   2 dimes

NOTE: Spacing around numbers is not critical.



Return to the Top of Page, First Page, Novice Problem Set, or Veteran Problem Set.


Clarifications:







Return to the Top of Page, First Page, or Novice Problem Set.



The statements and opinions included in these pages are those of the LSU High School Programming Contest Staff only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 1999 LSU High School Programming Contest

Return to the LSU High School Programming Contest Homepage