标签:log ret 分析 超过 span use 练习 使用 blog
问题:
企业发放的奖金根据利润提成。
从键盘输入当月利润I,求应发放奖金总数?
分析:使用变量来代替利润和奖金,用判断来输出奖金
代码:
function getnum($a){ $profit = $a; if($profit<= 10){ $bonuses = $profit*0.1; }else if($profit>10 || $profit<=20){ $bonuses = ($profit-10)*0.075 + 10*0.1; }else if($profit>20 || $profit<=40){ $bonuses = ($profit-20)*0.05 + 10*0.1 + 10*0.75; }else if($profit>40 || $profit<=60){ $bonuses = ($profit-40)*0.03 + 20*0.05 + 10*0.1 + 10*0.75; }else if($profit>60 || $profit<=100){ $bonuses = ($profit-60)*0.015 + 20*0.03 + 20*0.05 + 10*0.1 + 10*0.75; }else{ $bonuses = ($profit-100)*0.01+40*0.015 + 20*0.03 + 20*0.05 + 10*0.1 + 10*0.75; } return $bonuses; } $a = getnum(12); echo $a;
标签:log ret 分析 超过 span use 练习 使用 blog
原文地址:http://www.cnblogs.com/chengzhongde/p/7278183.html