Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #%% [markdown]
- # Execise
- # ATM System
- # เขียนโปรแกรมคำนวณจำนวนแบงค์แต่ละชนิด จากการกดตู้ ATM ซึ่งกำหนดให้
- # - ตู้นี้สามารถจ่ายแบงค์ประเภท 1000,500,100,50,20,10 บาท เท่านั้น
- # - ไม่สามารถจ่ายเป็นเหรียญได้
- # ตัวอย่างการทำงาน
- # Money = 2750
- # ..............
- # ....... You Code Here
- # ...............
- # Output
- # You money = 2750 bath
- # youget:
- # "1000" bath note = 2
- # "500" bath note = 1
- # "100" bath note = 2
- # "50" bath note = 1
- # "20" bath note = 0
- # "10" bath note = 0
- #%%
- x = 7885
- y = x%1000
- z = y%500
- a = z%100
- b = a%50
- c = b%20
- d = c%10
- if d != 0:
- print("Invalid input: This ATM cannot give coins")
- elif x < 0:
- print("error plase try again")
- else:
- print("Your money =" , x)
- print( "1000 bath note =" , x//1000)
- print("500 bath note =" , y//500)
- print("100 bath note =" , z//100)
- print("50 bath note =" , a//50)
- print("20 bath note =" , b//20)
- print("10 bath note =" , c//10)
- #%%
- money = 3884
- note_1000 = int(money/1000)
- change_1000 = money % 1000
- note_500 = int(change_1000/500)
- change_500 = change_1000 % 500
- note_100 = int(change_500/100)
- change_100 = change_500 % 100
- note_50 = int(change_100 / 50)
- change_50 = change_100 % 50
- note_20 = int(change_50 / 20)
- change_20 = change_50 % 20
- note_10 = int(change_20 / 10)
- change_10 = change_20 % 10
- if change_10 != 0:
- print("Invalid input: This ATM cannot give coins please enter a new number")
- else:
- ##-----------------output
- print("Your request = " + str(money) + " bath")
- print("you get:")
- print("1000 bath note = " + str(note_1000))
- print("500 bath note = " + str(note_500))
- print("100 bath note = " + str(note_100))
- print("50 bath note = " + str(note_50))
- print("20 bath note = " + str(note_20))
- print("10 bath note = " + str(note_10))
- #%%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement