酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

写python.某企业为职工发放奖金:如果入职超过5年,且销售业绩超过15000元的员工,奖全比例为0.2;销售业绩超过10000元的员工,奖金比例为0.15;销售业绩超过5000元的员工,奖金比例为0.1;其他奖金比例为0.05。如果入职不超过5年,且销售业绩超4000元的员工,奖金比例为0.045;否则为0.01。输入入职年限、销售业绩输出奖金比例、奖金,并将奖金存放到列表中,然后输出该列表。入职年限(为整数)输入一1时结束输入。为 了简化,所有输入均假定正确,无须判断小于0的情况。奖金为销售业绩与奖金比例的 乘积。

```python bonus_list = [] while True: years_of_service = int(input("请输入入职年限:")) if years_of_service == -1: break sales_performance = float(input("请输入销售业绩:")) if years_of_service > 5: if sales_performance > 15000: bonus_ratio = 0.2 elif sales_performance > 10000: bonus_ratio = 0.15 elif sales_performance > 5000: bonus_ratio = 0.1 else: bonus_ratio = 0.05 else: if sales_performance > 4000: bonus_ratio = 0.045 else: bonus_ratio = 0.01 bonus = sales_performance * bonus_ratio bonus_list.append(bonus) print(bonus_list) ``` [2024-11-07 01:01:17 | AI写代码神器 | 215点数解答]

相关提问