Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You're working at your neighbourhood convenience store, and sometimes it's difficult to figure out how many bills and coins to give back as change when
You're working at your neighbourhood convenience store, and sometimes it's difficult to figure out how many bills and coins to give back as change when customers don't give you the exact amount for what they bought. In a fit of brilliance, you decide to write a Python program to help! For example, if you need to give $33.70 in change back to the customer, you would give 1 twenty-dollar bill, 1 ten- dollar bill, 1 twonie (two-dollar coin), 1 loonie (one-dollar coin), 2 quarters, and 1 dime. To figure this out, you would do the following: Take the original amount of $33.70 and divide it by $20 to see how many $20 bills to give: this gives 1, and the remainder would be $13.70. Take $13.70 and divide it by $10 to see how many $10 bills to give: this gives 1, and the remainder would be $3.70. Take $3.70 and divide it by $5 to see that O five-dollar bills are needed. Remainder is unchanged. Take $3.70 and divide it by $2 to see that 1 twonie is needed, and remainder of $1.70. Take $1.70 and divide it by $1 to see that 1 loonie is needed, and reminder of $0.70. Take $0.70 and divide it by $0.25 to see that 2 quarters are needed, and remainder of $0.20. Take $0.20 and divide it by $0.10 to see that 2 dimes are needed, and remainder of $0.00 You can continue to divide the $0.00 by $0.05 to see that O nickels are needed. Write a Python program that can calculate the numbers of bills and coins needed for each denomination of currency for an amount given by the user. Your output should be formatted like the sample runs below. Sample Runs Enter the amount of money to make change for: 47.25 Amount of $20.00 : 2 Amount of $5.00: 1 Amount of $2.00: 1 Amount of $0.25: 1 Enter the amount of money to make change for: 3.92 Amount of $2.00: 1 Amount of $1.00: 1 Amount of $0.25: 3 Amount of $0.10: 1 Amount of $0.05: 1 Enter the amount of money to make change for: 158.95 Amount of $20.00: 7 Amount of $10.00 : 1 Amount of $5.00: 1 Amount of $2.00: 1 Amount of $1.00 : 1 Enter the amount of money to make change for: 0.80 Amount of $0.25: 3 Amount of $0.05: 1
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