So the goal is to convert money to the possible coins you can have
my code so far:
def make_change(amount):
q_f = (amount // .25)
d_f = (amount - (q_f * .25)) // .10
n_f = (amount - ((q_f * .25) + (d_f * .10 ))) // .05
p_f = (amount - ((q_f * .25) + (d_f * .10) + (n_f * .05))) //.01
q = int(q_f)
d = int(d_f)
n = int(n_f)
p = int(p_f)
change = "" + str(q) + " quarter(s), " + str(d) + " dime(s), " + str(n) + " nickel(s) and
" + str(p) + " penny(ies) "
return (change)
the problem is, say you input make_change(.19), the pennies are 3 instead of 4 because of the round-off error, is there a different way to write my code so the round-of error won't happen?