pythonExample100/JCP002.py

31 lines
1.0 KiB
Python
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

'''
【程序2】
题目:企业发放的奖金根据利润提成。利润(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求应发放奖金总数
1.程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。      
2.程序源代码:
'''
bonus1 = 100000 * 0.1
bonus2 = bonus1 + 100000 * 0.500075
bonus4 = bonus2 + 200000 * 0.5
bonus6 = bonus4 + 200000 * 0.3
bonus10 = bonus6 + 400000 * 0.15
i = int(raw_input('input gain:\n'))
if i <= 100000:
bonus = i * 0.1
elif i <= 200000:
bonus = bonus1 + (i - 100000) * 0.075
elif i <= 400000:
bonus = bonus2 + (i - 200000) * 0.05
elif i <= 600000:
bonus = bonus4 + (i - 400000) * 0.03
elif i <= 1000000:
bonus = bonus6 + (i - 600000) * 0.015
else:
bonus = bonus10 + (i - 1000000) * 0.01
print 'bonus = ',bonus