-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_return.py
52 lines (37 loc) · 1.11 KB
/
change_return.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
A small python program that
calculates the differentiated denominations
that the amount due can be returned in
"""
cost = int(raw_input("Enter the cost: "))
amount_given = int(raw_input("Enter the money given: "))
return_amount = amount_given - cost
hundreds=0
fifties=0
twenties=0
tens=0
fives=0
twos=0
ones=0
if return_amount >= 100:
hundreds = return_amount/100
return_amount = return_amount%100
if return_amount >= 50:
fifties = return_amount/50
return_amount = return_amount%50
if return_amount >= 20:
twenties = return_amount/20
return_amount = return_amount%20
if return_amount >= 10:
tens = return_amount/10
return_amount = return_amount%10
if return_amount >= 5:
fives = return_amount/5
return_amount = return_amount%5
if return_amount >= 2:
twos = return_amount/2
return_amount = return_amount%2
if return_amount >= 1:
ones = return_amount/1
return_amount = return_amount%1
print 'Your change in denominations: \n Hundreds(100) : %d \n Fifties(50) : %d \n Twenties(20) : %d \n Tens(10) : %d \n Fives(5) : %d \n Twos(2) : %d \n Ones(1) : %d' % (hundreds,fifties,twenties,tens,fives,twos,ones)