To modify the program so that the user can input the amount paid, you need to ask the user for the amount they paid and use this to calculate the change owed instead of hardcoding the 100 cents (which represents the total cost of an item).
The correct choice is:
Add a line below line 1 and enter the following on it: amountPaid = int(input("How much did you pay in cents?"))
, then change the 100 in the amountOwed
calculation to amountPaid
.
Here is the modified code:
amount = int(input("How much does your item cost in cents?"))
amountPaid = int(input("How much did you pay in cents?")) # User inputs the amount paid
amountOwed = amountPaid - amount # Change the calculation to subtract the item cost from amount paid
print(amountOwed // 25, "quarters")
amountOwed = amountOwed % 25
print(amountOwed // 10, "dimes")
amountOwed = amountOwed % 10
print(amountOwed // 5, "nickels")
amountOwed = amountOwed % 5
print(amountOwed // 1, "pennies")
This allows the user to enter both the cost of the item and the amount paid, and it calculates the change accordingly.