While my code works with some inputs, on other occasions it will round when no rounding is needed (.55 to .56 for example) I'm sure this is a very obvious mistake I've made in the code but I just cant wrap my mind around it.
while True:
cost = float(input("How much will that be? "))
payment = float(input("How much are you paying? "))
if payment >= cost:
break
print("Insufficient funds")
# end while
change = payment - cost
remainder = (int(change * 100) % 5)
if remainder == 0:
rounded = (change * 100)/100
elif remainder in [1,2]:
rounded = ((change * 100)-remainder)/100
elif remainder in [3,4]:
rounded = ((change * 100)+5-remainder)/100
print("Total cost Amount paid Change Rounded Change")
print("{0:.2f} {1:.2f} {2:.2f} {3:.2f}".format(cost, payment, change,
rounded))