Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Welcome to Chris's vending machine\n")
- print("Product Price Code")
- print("Mineral Water RM1 12 ")
- print("Wonda Coffee RM2 13")
- print("Chocolate Milk RM2 14")
- print("Coke RM2 15")
- print("Kitkat RM3 16")
- print("Redbull RM3 17")
- print("Snickers RM4 18")
- print("Chocolate_Bun RM5 19")
- print("CookiesCream RM5 20")
- Mineral_WaterPrice = 1
- KitkatPrice = 2
- Wonda_CoffeePrice = 2
- Chocolate_MilkPrice = 2
- RedbullPrice = 3
- CokePrice = 3
- SnickersPrice = 4
- Chocolate_BunPrice = 5
- CookiescreamPrice = 5
- print("Type a product code to continue...")
- userCode = int(input())
- if userCode == 12:
- print("You have selected Mineral Water. Pay RM1")
- elif userCode == 13:
- print("You have selected Wonda Coffee. Pay RM2")
- elif userCode == 14:
- print("You have selected Chocolate Milk. Pay RM2")
- elif userCode == 15:
- print("You have selected Coke. Pay RM2")
- elif userCode == 16:
- print("You have selected Kitkat. Pay RM3")
- elif userCode == 17:
- print("You have selected Redbull. Pay RM3")
- elif userCode == 18:
- print("You have selected Snickers. Pay RM4")
- elif userCode == 19:
- print("You have selected Chocolate Bun. Pay RM5")
- elif userCode == 20:
- print("You have selected Cookies n Cream. Pay RM5")
- cost = float(input('Cost: '))
- amount_paid = float(input('Amount paid: '))
- penny = 0.01
- dime = 0.10
- quarter = 0.25
- dollar_RM1 = 1.00
- dollar_RM5 = 5.00
- dollar_RM10 = 10.00
- dollar_RM20 = 20.00
- dollar_RM50 = 50.00
- dollar_RM100 = 100.00
- changeTypes = {dollar_RM100: 0, dollar_RM50: 0, dollar_RM20: 0, dollar_RM10: 0, dollar_RM5: 0, dollar_RM1: 0,
- quarter: 0, dime: 0, penny: 0}
- change = amount_paid - cost
- if amount_paid < cost:
- print('Error: InsufficientFunds')
- for changeType in changeTypes:
- numAmount = max(0, change // changeType)
- change -= numAmount * changeType
- changeTypes[changeType] = int(numAmount)
- print(changeTypes)
Advertisement
Add Comment
Please, Sign In to add comment