Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #%% [markdown]
  2. # Execise
  3. # ATM System
  4. # เขียนโปรแกรมคำนวณจำนวนแบงค์แต่ละชนิด จากการกดตู้ ATM ซึ่งกำหนดให้
  5. # - ตู้นี้สามารถจ่ายแบงค์ประเภท 1000,500,100,50,20,10 บาท เท่านั้น
  6. # - ไม่สามารถจ่ายเป็นเหรียญได้
  7. # ตัวอย่างการทำงาน
  8. # Money = 2750
  9. # ..............
  10. # ....... You Code Here
  11. # ...............
  12. # Output
  13. # You money = 2750 bath
  14. # youget:
  15. # "1000" bath note = 2
  16. # "500" bath note = 1
  17. # "100" bath note = 2
  18. # "50" bath note = 1
  19. # "20" bath note = 0
  20. # "10" bath note = 0
  21.  
  22. #%%
  23. x = 7885
  24. y = x%1000
  25. z = y%500
  26. a = z%100
  27. b = a%50
  28. c = b%20
  29. d = c%10
  30. if d != 0:
  31. print("Invalid input: This ATM cannot give coins")
  32. elif x < 0:
  33. print("error plase try again")
  34. else:
  35. print("Your money =" , x)
  36. print( "1000 bath note =" , x//1000)
  37. print("500 bath note =" , y//500)
  38. print("100 bath note =" , z//100)
  39. print("50 bath note =" , a//50)
  40. print("20 bath note =" , b//20)
  41. print("10 bath note =" , c//10)
  42.  
  43.  
  44. #%%
  45. money = 3884
  46.  
  47. note_1000 = int(money/1000)
  48. change_1000 = money % 1000
  49.  
  50. note_500 = int(change_1000/500)
  51. change_500 = change_1000 % 500
  52.  
  53. note_100 = int(change_500/100)
  54. change_100 = change_500 % 100
  55.  
  56. note_50 = int(change_100 / 50)
  57. change_50 = change_100 % 50
  58.  
  59. note_20 = int(change_50 / 20)
  60. change_20 = change_50 % 20
  61.  
  62. note_10 = int(change_20 / 10)
  63. change_10 = change_20 % 10
  64.  
  65. if change_10 != 0:
  66. print("Invalid input: This ATM cannot give coins please enter a new number")
  67. else:
  68.  
  69.  
  70. ##-----------------output
  71.  
  72. print("Your request = " + str(money) + " bath")
  73. print("you get:")
  74. print("1000 bath note = " + str(note_1000))
  75. print("500 bath note = " + str(note_500))
  76. print("100 bath note = " + str(note_100))
  77. print("50 bath note = " + str(note_50))
  78. print("20 bath note = " + str(note_20))
  79. print("10 bath note = " + str(note_10))
  80.  
  81.  
  82.  
  83. #%%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement