- print("*** 智慧找零系統 ***")
- price=int(input("請輸入商品價格: "))
- pay=int(input("客人付了多少錢: "))
- money=pay-price
- print("\n需找客人",money,"元\n")
- if money>=500:
- print("五百元鈔票",money//500,"張")
- money%=500
- if money>=100:
- print("一百元鈔票",money//100,"張")
- money%=100
- if money>=50:
- print("五十元硬幣",money//50,"枚")
- money%=50
- if money>=10:
- print("十元硬幣",money//10,"枚")
- money%=10
- if money>=5:
- print("五元硬幣",money//5,"枚")
- money%=5
- if money>=1:
- print("一元硬幣",money,"枚")
複製代碼 |