Whenever I enter the required output example of putting 5.14 as the input. I get the correct quarter, dime, and nickel values but the pennies value is showing as 3 pennies instead of 4. However, when I do an input of 3.14 or 4.14 it shows the right value of 4 pennies.
amount = float(input("Please input the amount of money to calculate the change:\n"))
quarters = (amount / 0.25)
minus_quarters = amount - (int(quarters) * 0.25)
dimes = (minus_quarters / 0.10)
minus_dimes = minus_quarters - (int(dimes) * 0.10)
nickels = (minus_dimes / 0.05)
minus_nickels = minus_dimes - (int(nickels) * 0.05)
pennies = (minus_nickels / 0.01)
print(f'The amount you entered is ${amount}')
print()
print(f'The number of coins for {amount} dollars are:')
print("Quaters:", int(quarters))
print("Dimes:", int(dimes))
print("Nickels:", int(nickels))
print("Pennies:", int(pennies))
I tried removing the "int" in the print statement but then it gave me a long decimal of 3.9999997