Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def AutoMagicChangeCounter():
- # Grab user input
- item_cost = float(input('Please enter how much your item cost: '))
- amount_paid = float(input('Please enter how much you paid for this item: '))
- total_change_due = amount_paid - item_cost
- total_whole_dollars_due = int(total_change_due)
- whole_remaining_cents = (int)((total_change_due - total_whole_dollars_due) * 100) # Splits cents from dollar amount
- print('Total change due: $' + str(total_change_due))
- # Twenties
- twenties = (int)(total_whole_dollars_due / 20) # Calculates how many 20's are to be paid out.
- total_whole_dollars_due -= 20 * twenties # Redefines how much change is to be paid out after twenties are paid.
- # Tens
- # tens = (int)(total_whole_dollars_due / 10)
- # total_whole_dollars_due -= 10 * tens
- # Fives
- fives = (int)(total_whole_dollars_due / 5)
- total_whole_dollars_due -= 5 * fives
- print('\nDollar Amounts Due: \n\nTwenties: ' + str(twenties))
- # print('Tens: ' + str(tens))
- print('Fives: ' + str(fives))
- print('Ones: ' + str(total_whole_dollars_due)) # The rest of the calcs leave total_whole_dollars_due
- # being equal to how many ones are left.
- # Cents: Quarters
- quarters = (int)(whole_remaining_cents / 25)
- whole_remaining_cents -= 25 * quarters
- # Dimes
- # dimes = (int)(whole_remaining_cents / 10)
- # whole_remaining_cents -= 10 * dimes
- # Nickels
- nickels = (int)(whole_remaining_cents / 5)
- whole_remaining_cents -= 5 * nickels
- print('\nChange Due:')
- print('Quarters: ' + str(quarters))
- print('Nickels: ' + str(nickels))
- print('Pennies: ' + str(whole_remaining_cents))
- AutoMagicChangeCounter()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement