Guest User

Untitled

a guest
Nov 29th, 2022
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. print("Welcome to Chris's vending machine\n")
  2. print("Product Price Code")
  3. print("Mineral Water RM1 12 ")
  4. print("Wonda Coffee RM2 13")
  5. print("Chocolate Milk RM2 14")
  6. print("Coke RM2 15")
  7. print("Kitkat RM3 16")
  8. print("Redbull RM3 17")
  9. print("Snickers RM4 18")
  10. print("Chocolate_Bun RM5 19")
  11. print("CookiesCream RM5 20")
  12.  
  13. Mineral_WaterPrice = 1
  14. KitkatPrice = 2
  15. Wonda_CoffeePrice = 2
  16. Chocolate_MilkPrice = 2
  17. RedbullPrice = 3
  18. CokePrice = 3
  19. SnickersPrice = 4
  20. Chocolate_BunPrice = 5
  21. CookiescreamPrice = 5
  22.  
  23. print("Type a product code to continue...")
  24.  
  25. userCode = int(input())
  26. if userCode == 12:
  27. print("You have selected Mineral Water. Pay RM1")
  28.  
  29. elif userCode == 13:
  30. print("You have selected Wonda Coffee. Pay RM2")
  31. elif userCode == 14:
  32. print("You have selected Chocolate Milk. Pay RM2")
  33. elif userCode == 15:
  34. print("You have selected Coke. Pay RM2")
  35. elif userCode == 16:
  36. print("You have selected Kitkat. Pay RM3")
  37. elif userCode == 17:
  38. print("You have selected Redbull. Pay RM3")
  39. elif userCode == 18:
  40. print("You have selected Snickers. Pay RM4")
  41. elif userCode == 19:
  42. print("You have selected Chocolate Bun. Pay RM5")
  43. elif userCode == 20:
  44. print("You have selected Cookies n Cream. Pay RM5")
  45.  
  46. cost = float(input('Cost: '))
  47. amount_paid = float(input('Amount paid: '))
  48. penny = 0.01
  49. dime = 0.10
  50. quarter = 0.25
  51. dollar_RM1 = 1.00
  52. dollar_RM5 = 5.00
  53. dollar_RM10 = 10.00
  54. dollar_RM20 = 20.00
  55. dollar_RM50 = 50.00
  56. dollar_RM100 = 100.00
  57. changeTypes = {dollar_RM100: 0, dollar_RM50: 0, dollar_RM20: 0, dollar_RM10: 0, dollar_RM5: 0, dollar_RM1: 0,
  58. quarter: 0, dime: 0, penny: 0}
  59. change = amount_paid - cost
  60. if amount_paid < cost:
  61. print('Error: InsufficientFunds')
  62. for changeType in changeTypes:
  63. numAmount = max(0, change // changeType)
  64. change -= numAmount * changeType
  65. changeTypes[changeType] = int(numAmount)
  66.  
  67. print(changeTypes)
Advertisement
Add Comment
Please, Sign In to add comment