Question
In this assignment you will design a program to give customers the correct change. Here are the parameters: The user will enter a number between
In this assignment you will design a program to give customers the correct change. Here are the parameters:
The user will enter a number between 1 and 99. If it is outside of that range, you will inform the user and exit the program.
You will loop through each coin denomination. You may not need to use the penny depending on the amount entered by the user.
For each denomination type, you will use a loop to determine if there are any more of that type left. For example, if you have 49 left, you will add one quarter, subtract 25 from 49, and check it again.
You should start from the largest denomination (half dollar).
Here are some hints (this is an example of the program running with 99 as the entry):
If the number is 99, you can 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".
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started