SHARE
TWEET

Untitled

a guest Sep 11th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def AutoMagicChangeCounter():
  2.    
  3.     # Grab user input
  4.    
  5.     item_cost = float(input('Please enter how much your item cost: '))
  6.     amount_paid = float(input('Please enter how much you paid for this item: '))
  7.    
  8.     total_change_due = amount_paid - item_cost
  9.     total_whole_dollars_due = int(total_change_due)
  10.     whole_remaining_cents = (int)((total_change_due - total_whole_dollars_due) * 100) # Splits cents from dollar amount
  11.    
  12.     print('Total change due: $' + str(total_change_due))
  13.    
  14.     # Twenties
  15.    
  16.     twenties = (int)(total_whole_dollars_due / 20) # Calculates how many 20's are to be paid out.
  17.     total_whole_dollars_due -= 20 * twenties # Redefines how much change is to be paid out after twenties are paid.
  18.    
  19.     # Tens
  20.    
  21.     # tens = (int)(total_whole_dollars_due / 10)
  22.     # total_whole_dollars_due -= 10 * tens
  23.    
  24.     # Fives
  25.    
  26.     fives = (int)(total_whole_dollars_due / 5)
  27.     total_whole_dollars_due -= 5 * fives
  28.    
  29.     print('\nDollar Amounts Due: \n\nTwenties: ' + str(twenties))
  30.     # print('Tens: ' + str(tens))
  31.     print('Fives: ' + str(fives))
  32.     print('Ones: ' + str(total_whole_dollars_due)) # The rest of the calcs leave total_whole_dollars_due
  33.                                                    # being equal to how many ones are left.
  34.        
  35.     # Cents: Quarters
  36.    
  37.     quarters = (int)(whole_remaining_cents / 25)
  38.     whole_remaining_cents -= 25 * quarters
  39.    
  40.     # Dimes
  41.    
  42.     # dimes = (int)(whole_remaining_cents / 10)
  43.     # whole_remaining_cents -= 10 * dimes
  44.    
  45.     # Nickels
  46.    
  47.     nickels = (int)(whole_remaining_cents / 5)
  48.     whole_remaining_cents -= 5 * nickels
  49.    
  50.     print('\nChange Due:')
  51.     print('Quarters: ' + str(quarters))
  52.     print('Nickels: ' + str(nickels))
  53.     print('Pennies: ' + str(whole_remaining_cents))
  54.    
  55. AutoMagicChangeCounter()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top