amount = int(input("How much does your item cost in cents?"))

amountOwed = 100 - amount
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")

Which of the following would correctly modify the program so that the user can input the amount paid. Follow this link to try them out! (2 points) Responses Add a line below line 1 and enter the following on it: amountPaid = 100, then change the 100 in the amountOwed calculation to amountPaid. Add a line below line 1 and enter the following on it: amountPaid = 100, then change the 100 in the amountOwed calculation to amountPaid. Remove 100 from line 2 and enter the following in its place: input("How much did you pay in cents?") Remove 100 from line 2 and enter the following in its place: input("How much did you pay in cents?") Add a line below line 1 and enter the following on it: amountPaid = input("How much did you pay in cents?") , then change the 100 in the amountOwed calculation to amountPaid. Add a line below line 1 and enter the following on it: amountPaid = input("How much did you pay in cents?") , then change the 100 in the amountOwed calculation to amountPaid. 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.

1 answer

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.