当前位置:网站首页>实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
2022-07-05 08:16:00 【懒笑翻】
实例002:“个税计算”
# **题目:**企业发放的奖金根据利润提成。 # 利润(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,求应发放奖金总数?
#题目分析 """ 当我们进行手算的时候,是这样算的:假设是1500000,是大于10000万的,下面我们来是手算: 10w*0.1+10w*0.075+20w*0.05+20w*0.03+40w*0.015+50w*0.01 """ # **程序分析:**分区间计算即可
依照我们手算的过程,在算法中,我们也根据区间来计算,如果输入的利润profit小于或等于 thresholds[i]时,则用profit计算完当前区间对应的利率加在奖金bonus上后就退出,否则就用当前区间对应的金额*对应区间的利率加在奖金bonus上后,profit再减掉当前区间对应的金额再进入for循环。在金额区间内的利率是有对应区间段利率的,高于100万的部分对应利率1%也就是0.01。如果在前面我们的利润是小于等于100万的,那么profit在走出循环的时候是0,在输出发放的奖金总数前计算的高于100万的奖金时就是0*0.01=0。
for j in range(10): # 可以测试10次
profit = int(input('请输入你的利润金额: ')) #input输入的是字符串类型,要用int()转为整数
bonus = 0
thresholds = [100000, 100000, 200000, 200000, 400000] # 分区间计算
rates = [0.1, 0.075, 0.05, 0.03, 0.015, 0.01]
for i in range(len(thresholds)):
print(profit, "--", i, "thresholds[i]", thresholds[i], "rates[i]", rates[i])
if profit <= thresholds[i]:
bonus += profit * rates[i]
profit = 0
break
else:
bonus += thresholds[i] * rates[i]
profit -= thresholds[i]
print(profit)
bonus += profit * rates[-1] # 这里就是计算高于100w部分的奖金
print(" 发放的奖金总数为: ", bonus)
输出结果:
请输入你的利润金额: 1500000
1500000 -- 0 thresholds[i] 100000 rates[i] 0.1
1400000
1400000 -- 1 thresholds[i] 100000 rates[i] 0.075
1300000
1300000 -- 2 thresholds[i] 200000 rates[i] 0.05
1100000
1100000 -- 3 thresholds[i] 200000 rates[i] 0.03
900000
900000 -- 4 thresholds[i] 400000 rates[i] 0.015
500000
发放的奖金总数为: 44500.0
边栏推荐
- matlab timeserise
- NTC thermistor application - temperature measurement
- More than 90% of hardware engineers will encounter problems when MOS tubes are burned out!
- Detailed explanation of pragma usage
- Stm32--- systick timer
- MySQL之MHA高可用集群
- Sql Server的存储过程详解
- Various types of questions judged by prime numbers within 100 (C language)
- Zero length array in GNU C
- STM32 single chip microcomputer -- volatile keyword
猜你喜欢
Consul安装
Interview catalogue
PMSM dead time compensation
C WinForm [help interface - send email] - practice five
Hardware and software solution of FPGA key chattering elimination
STM32 single chip microcomputer -- debug in keil5 cannot enter the main function
Improve lighting C program
Management and use of DokuWiki
Circleq of linked list
Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine
随机推荐
General makefile (I) single C language compilation template
Bluetooth hc-05 pairing process and precautions
Shell script basic syntax
Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
STM32 outputs 1PPS with adjustable phase
Google sitemap files for rails Projects - Google sitemap files for rails projects
Weidongshan Internet of things learning lesson 1
Programming knowledge -- assembly knowledge
Makefile application
Shell script realizes the reading of serial port and the parsing of message
OC and OD gate circuit
Solutions to compilation warnings in Quartus II
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
Network port usage
VESC Benjamin test motor parameters
C WinForm [view status bar -- statusstrip] - Practice 2
Consul安装
Fundamentals of C language
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
Brief discussion on Buck buck circuit