【王道JAVA】【程序 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%提成,从键盘输入当月利润,求应发放奖金总数?

import java.util.Scanner;

public class WangDao {
	public static void main(String[] args){
		System.out.print("Enter your profit: (nuit:100,000)");
		Scanner scan = new Scanner(System.in);
		long profit = scan.nextLong();
		double reward = 0;
		
		if (profit > 100) {
			reward += (profit - 100) * 0.01;
			profit = 100;
		}
		if (profit >= 60) {
			reward += (profit - 60) * 0.015;
			profit = 60;
		}
		if (profit >= 40) {
			reward += (profit - 40) * 0.03;
			profit = 40;
		}
		if (profit >= 20) {
			reward += (profit - 20) * 0.05;
			profit = 20;
		}
		if (profit >= 10) {
			reward += (profit - 10) * 0.075;
			profit = 10;
		}
		if (profit >= 0) {
			reward += profit * 0.1;
		}
		System.out.println("Your reward is " + reward);
	}
}

猜你喜欢

转载自blog.csdn.net/YelloJesse/article/details/89375923