/*【程序12】
题目:企业发放的奖金根据利润提成。利润(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,求应发放奖金总数? */
package test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class test {
public static double bonus(double profit) {
double result = 0;
if (profit <= 100000)
result = 0.1 * profit;
else {
result = 10000;
if (profit > 100000 && profit <= 200000)
result = result + 0.075 * (profit - 100000);
else {
result = result + 0.075 * 100000;
if (profit > 200000 && profit <= 400000)
result = result + 0.05 * (profit - 200000);
else {
result = result + 0.05 * 200000;
if (profit > 400000 && profit <= 600000)
result = result + 0.03 * (profit - 400000);
else {
result = result + 0.03 * 200000;
if (profit > 600000 && profit <= 1000000)
result = result + 0.015 * (profit - 600000);
else {
result = result + 0.015 * 400000;
if (profit > 1000000)
result = result + 0.01 * (profit - 1000000);
}
}
}
}
}
return result;
}
public static void main(String args[]) {
String profit = null;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
System.out.println("请输入当月利润:");
profit = br.readLine();
} catch (Exception e) {
}
double tempPro = Double.parseDouble(profit);
double bonus = bonus(tempPro);
System.out.println("本月奖金为: " + bonus);
}
}
这个应该怎么改进呢?
转载于:https://blog.51cto.com/gomic/1417627