Question: Task 10 (5 points) Write a Python script that will calculate the change due, if any, for a given payment and for a random cost,
Task 10 (5 points)
Write a Python script that will calculate the change due, if any, for a given payment and for a random cost, based on a given string of coin values. If the payment is made with exact change, no change will be due. If the payment is over the total amount, then the output will be the change due. If the payment is under the total amount, the output will be how much more is needed. Your script should also provide input checking to ensure that only digits are being entered and are in the correct format before doing any calculations and it should loop continuously until the user enters "quit.
| Input string | Expected output of script |
| Cost is 17.61 Enter a payment: 15.25 Enter a list of coin values: 1, .35, .23, .12, .03, .01 Cost is 7.88 Enter a payment: 20.00 Enter a list of coin values: 1, .35, .23, .12, .03, .01 Cost is 45.25 Enter a payment: quit | needed: 2 1 coins, 1 .35 coins, 1 .01 coins, change: 12 1 coins, 1 .12 coins, Goodbye! |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
