java代码求奖金。要求从键盘输入利润
总结:看似文字描述很多,
package com.ai; import java.util.Scanner; import com.b.Scaner; //v企业发放的奖金根据利润提成。利润(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%提成, //从键盘输入当月利润,求应发放奖金总数? public class PrizeCommision { static long prize; static long prift; public static void main(String[] args) { Scanner c = new Scanner(System.in); while (true) { System.out.println("当前利润是:"); prift = c.nextLong(); if (prift > 0) break; } if (prift <= 10000) { prize = (long) (prift * .1); } else if (prift < 20000) { prize = (long) (10000 * .1 + (prift - 10000) * 0.75); } else if (prift < 40000) { prize = (long) (10000 * .1 + 10000 * .075 + (prift - 20000) * .05); } else if (prift < 60000) { prize = (long) (1000 * .1 + 1000); prize = (long) (10000 * .1 + 10000 * .075 + 20000 * .05 + (prift - 60000) * .03); } else if (prift < 1000000) { prize = (long) (10000 * .1 + 10000 * .075 + 20000 * .05 + 60000 * .03 + (prift - 1000000) * .15); } else { prize = (long) (10000 * .1 + 10000 * 0.75 + 20000 * .05 + 60000 * .03 + (prift - 1000000) * .01); } System.out.println("该得的奖金为:" + prize); } }