Candy Store Cashier Algorithm

Design an algorithm for the following problem:

You are a cashier in a candy store. Each of your customers buys exactly one item costing $1.00 or less. Each customers pays for the item with exactly $1.00. Your job is to give each customer the correct amount of change in some combination of pennies, nickels, dimes, and quarters. The combination must be the minimum number of coins. For example, if the item cost is $.38, the change would be 2 quarters, 1 dime, 0 nickels, and 2 pennies ($.62). The input is composed of customer records, each containing customer name and item cost. The output is composed of lines, each containing customer name, item cost, change, number of quarters, number of dimes, number of nickels, and number of pennies. A cost of $0.00 will be used to signal the end of the input.

Leave a Reply

Your email address will not be published. Required fields are marked *

  • File Format: MS-Word .docx
  • Word Count: 147