gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
用matlab写出企业发放的奖金根据利润提成。利润低于或等于10万元的,奖金可提10%;利润高于10万元低于等于20万元时,低于10万元的部分按10%提成,高于10万的部分可提成…
- User
用matlab写出企业发放的奖金根据利润提成。利润低于或等于10万元的,奖金可提10%;利润高于10万元低于等于20万元时,低于10万元的部分按10%提成,高于10万的部分可提成7.5%;利润高于20万元低于等于40万元时,低于20万的部分仍按上述办法提成(下同)高于20万的部分可提成5%;利润高于40万元低于等于60万元时,高于40万的部分可提成3%;利润高于60万元低于等于100万元时,高于60万元的部分按1.5%提成,高于100万的部分可提成1%;从键盎输入当月利润,求应发奖金总数。
- Assistant
下面是使用MATLAB编写的解决方案:
function bonus = calculateBonus(profit) if profit <= 100000 bonus = profit * 0.1; elseif profit <= 200000 bonus = 100000 * 0.1 + (profit - 100000) * 0.075; elseif profit <= 400000 bonus = 100000 * 0.1 + 100000 * 0.075 + (profit - 200000) * 0.05; elseif profit <= 600000 bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (profit - 400000) * 0.03; elseif profit <= 1000000 bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + (profit - 600000) * 0.015; else bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + 400000 * 0.015 + (profit - 1000000) * 0.01; end end要使用该函数,只需调用
calculateBonus函数,并将当月利润作为参数传递:profit = input("请输入当月利润:"); bonus = calculateBonus(profit); disp("应发奖金总数为:" + bonus + " 元。")请注意,上述代码假设当月利润是以元为单位的。如果输入的利润单位是万元,则需要进行相应的调整。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.