Change Return Program

"""
Q. Change Return Program - The user enters a cost and then the amount of money given. The program will
   figure out the change and the number of quarters, dimes, nickels, pennies needed for the change.
"""
#import math module 
import math

def Change_Return_Program(denom,money):
    i   = 0
    used= [0]*len(denom)
    while(money >0):# go until all money gone
        
        num = math.floor(money/denom[i]) 
        used[i] = num # say we've used it
        money = money-num*denom[i] # set new 
        i = i + 1 # go to next denom
    return used

Leave a comment