Convert a coin amount to dollars, quarters, dimes, nickels, and pennies.   #


import math cents = 257 dollars = 0 quarters = 0 dimes = 0 nickels = 0 pennies = 0 dollars = int(cents/100) cents = cents - (dollars*100) quarters = math.trunc(cents/25) cents = cents - (quarters*25) dimes = math.trunc(cents/10) cents = cents - (dimes*10) nickels = math.trunc(cents/5) cents = cents - (nickels*5) pennies = cents print ("Dollars : " + str(dollars) + ",Quarters : " + str(quarters)+ ",Dimes : " + str(dimes) + ",Nickels : " + str(nickels) + ",Pennies : " + str(pennies))

Loading Please Wait...