-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeReturn.py
More file actions
executable file
·44 lines (25 loc) · 1.29 KB
/
changeReturn.py
File metadata and controls
executable file
·44 lines (25 loc) · 1.29 KB
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
"""
The program will figure out the change and the number of
quarters, dimes, nickels, pennies needed for the change.
The user have to enter the price of an item and the amount of money given
"""
def calculateChange(change_to_return):
ones=change_to_return/100
change_after_ones = change_to_return % 100
quarters=change_after_ones/25
change_after_quarters = change_after_ones-(quarters*25)
dimes=change_after_quarters/10
change_after_dimes=change_after_quarters-(dimes*10)
nickels=change_after_dimes/5
change_after_nickels=change_after_dimes-(nickels*5)
pennies=change_after_nickels
return ones,quarters,dimes,nickels,pennies
if __name__=="__main__":
price_of_item = int(float(raw_input("Enter the Total Amount:"))*100)
amount_paid = int(float(raw_input("Enter the Amount Paid:"))*100)
change_to_return = amount_paid - price_of_item
change_to_print = float(change_to_return)/100
print "The Amount to be returned:%s" %change_to_print
print "The Distribution of Money is:"
ones,quarters,dimes,nickels,pennies = calculateChange(change_to_return)
print "ones=%s,quarters=%s,dimes=%s,nickels=%s,pennies=%s" %(ones,quarters,dimes,nickels,pennies)