what would be the easiest way to use python for calculating the coins with the different quarter, dime, noony, penny ? I've seen some declaration with an array of values ? And waht i've done isn t working because i can't figure out how to order with python to use largest coins ?? Any hints please ??
that the result I get :
~/workspace/pset6/ $ python greedy.py
Oh Hai ! How much change is owed?
0.41
164.0
here section of code :
else:
#convert the input integer in rouded money +
#convert the dollars in cents
amount_cents = (round((amount_dollars)*100))
#while True:
#loop until there is still change
if amount_cents > 0:
# number of coins
q = (amount_cents/0.25)
amount_remain_q = (amount_cents-(q*0.25))
d = (amount_remain_q/0.10)
amount_remain_d = (amount_remain_q-(d*0.10))
n = (amount_remain_d/0.05)
amount_remain_n = (amount_remain_d-(n*0.05))
p = (amount_remain_n/0.01)
#number of total coins
coins = q+d+n+p
print(coins)