# Computing change # Author: Dan Fleck # Pseudocode: # Ask for cost # Ask for payment # Compute number of dollars # Compute number of quarters # Compute dimes, nickels, pennies # Output to the user def getCostAndPayment(): cost, payment = input("What is the cost and payment ->") return cost,payment def getDollars(change): dollars = int(change) return dollars def getChange(chg, dollars): # Temp: 2.56 chg = chg - dollars chg = int(chg * 100) quarters = chg / 25 chg = chg % 25 dimes = chg / 10 chg = chg % 10 nickels = chg / 5 chg %= 5 pennies = chg return quarters, dimes, nickels, pennies def main(): # Ask for cost and payment cost, payment = getCostAndPayment() print "DEBUG: Cost:",cost," PYMT:", payment change = payment - cost dollars = getDollars(change) print "Change:", change print "Dollars:", dollars quarters, dimes, nickels, pennies = getChange(change, dollars) print quarters, dimes, nickels, pennies print str(quarters).rjust(10) main()