posted 8 years ago
a program to give customers the correct change. Here are the parameters:
1) Coins to use and their values: Half Dollars (50) Quarter Dollars (25) Dimes (10) Nickels (5) Pennies (1)
The user will enter a number between 1 and 99. If the number is outside of that range, you will inform the user and terminate the program.
You will use as few coins as possible. For example, if the user enters "50", you will give the answer as "One Half Dollar" and not "5 Dimes" or "50 Pennies".
You will loop through each coin denomination, with the possible exception of the penny. Here is a hint:
If the number is 99, then subtract 50 from the number using a loop. This leaves 49, with one half dollar used.
Next, subtract 25 from the total using a loop. This leaves 24, with one quarter used
Next, subtract 10 cents from the total in a loop. This will leave 4 cents, with two dimes used.
Finally record the four pennies left over.
The output should read something like: "You have one half dollar, one quarter, two dimes, and four pennies".