您的位置:首页 > 编程语言 > Java开发

java每日小算法(12)

2014-05-27 14:25 519 查看
/*【程序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);
}
}
这个应该怎么改进呢?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息