# Program to make change # Matt Bishop, July 11, 2012 # for COSMOS 2012, Cluster 4 # set flag for looping go_on = "yes" # # loop making change until told to quit # while go_on == "yes": # get the amount to make change for temp = input("How many cents do you want me to make change for? ") change = pchange = int(temp) # take out the qurters nquarters = change // 25 change %= 25 # take out the dimes ndimes = change // 10 change %= 10 # take out the nickels nnickels = change // 5 # what's left are the pennies npennies = change % 5 # give the change print(pchange, "cents is", nquarters, "quarters,", ndimes, "dimes,", nnickels, "nickels, and ", npennies, "pennies") # do another one? try: go_on = input("Again ('yes' for yes, anything else to stop): ") except EOFError: go_on = "no"