java一般项目提成多少_java编程题目,企业发放的奖金根据利润提成

时间:2025-04-09 08:11:06

java编程题你做过多少呢?下面要给大家分享的同样是一道非常基础的java编程题,来看看题目,和编程写法吧。

一、题目

企业发放的奖金根据利润提成。

利润(I)低于或者是等于10万元的时候,奖金可提10%;

利润高于10万元,低于20万元的时候,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;

20万到40万之间的时候,高于20万元的部分,可以提成5%;

40万到60万之间的时候,高于40万元的部分,可以提成3%;

60万到100万之间的时候,高于60万元的部分,可以提成1.5%;

60万到100万之间的时候,高于100万元的时候,超过100万元的部分按1%提成,从键盘输入当月利润I。

求:

应发放奖金总数

二、思路

利用数轴来分界,定位。

注:

定义的时候,要将奖金定义成长整型。

三、代码实现import .*;

public class Prog12

{

public static void main(String[] args)

{

("请输入当前利润:");

long profit = (key_Input());

("应发奖金:" + bonus(profit));

}

//接受从键盘输入的内容

private static String key_Input()

{

String str = null;

BufferedReader bufIn = new BufferedReader(new InputStreamReader());

try

{

str = ();

}

catch (IOException e)

{

();

}

finally

{

try

{

();

}

catch (IOException e)

{

();

}

}

return str;

}

//计算奖金

private static long bonus(long profit)

{

long prize = 0;

long profit_sub = profit;

if (profit > 1000000)

{

profit = profit_sub - 1000000;

profit_sub = 1000000;

prize += profit * 0.01;

}

if (profit > 600000)

{

profit = profit_sub - 600000;

profit_sub = 600000;

prize += profit * 0.015;

}

if (profit > 400000)

{

profit = profit_sub - 400000;

profit_sub = 400000;

prize += profit * 0.03;

}

if (profit > 200000)

{

profit = profit_sub - 200000;

profit_sub = 200000;

prize += prize * 0.05;

}

if (profit > 100000)

{

profit = profit_sub - 100000;

profit_sub = 100000;

prize += profit * 0.075;

}

prize += profit_sub * 0.1;

return prize;

}

}

更多基础java编程题,欢迎继续关注奇Q工具网的java实例栏目来了解哦。

推荐阅读: