企业发放的奖金根据利润提成

"""
题目:企业发放的奖金根据利润提成。利润
(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()
	
	
	
posted @ 2017-12-03 20:56  苏幕遮_凌枫  阅读(1094)  评论(0编辑  收藏  举报