1. 程式人生 > >企業發放的獎金根據利潤提成

企業發放的獎金根據利潤提成

nis exce try pri mark orm exe 鍵盤 超過

"""
題目:企業發放的獎金根據利潤提成。利潤
(I) : 
低於或等於 10 萬元時,獎金可提
10% ; 
高於 10 萬元,低於 20 萬元時,低於 10 萬元的部分按 10% 提成,高於 10
萬元的部分,可提成
7.5%; 
20 萬到 40 萬之間時,高於 20 萬元的部分,可提成 5% ; 
40 萬到 60 萬之間時,高於 40 萬元的部分,可提成 3% ; 
60 萬到 100 萬之間時,高於
60 萬元的部分,可提成
1.5%, 
高於 100 萬元時, 
超過 100 萬元的部分按 1% 提成, 
從鍵盤輸入當月利潤
I ,求應發放獎金總數?
"""


def calculate_bonus(profit):
    bonus = 0
    if profit <= 10:
        bonus = profit * 0.1
    elif profit <= 20:
        bonus = (profit - 10) * 0.075 + 10 * 0.1
    elif profit <= 40:
        bonus = (profit - 20) * 0.05 + 10 * 0.1 + 10 * 0.075
    elif profit <= 60:
        bonus = (profit - 40) * 0.03 + 10 * 0.1 + 10 * 0.075 + 20 * 0.05
    elif profit <= 100:
        bonus = (profit - 60) * 0.03 + 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03
    elif profit > 100:
        bonus = (profit - 100) * 0.01 + 10 * 0.1 + 10 * 0.075 + 20 * 0.05 +20 * 0.03 + 40 * 0.015
    return bonus


def get_info():
    try:
        info = input("利潤?")
        profit = int(info)
        if profit >0:
            result = calculate_bonus(profit)
            print("根據利潤值{}萬元,獎金金額是{}萬元".format(profit, result))
        else:
            print("profit can not be below 0")
    except Exception as e:
        print(e)
    else:
        print("finish")
    finally:
        print("method get_info executed")
    

if __name__ == ‘__main__‘:
    get_info()
    
    
    

企業發放的獎金根據利潤提成