zoukankan      html  css  js  c++  java
  • JAVA 基础编程练习题12 【程序 12 计算奖金】

    12 【程序 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 cskaoyan;
    
    public class cskaoyan12 {
    	@org.junit.Test
    	public void count() {
    		java.util.Scanner in = new java.util.Scanner(System.in);
    		double profit = in.nextDouble();
    		double bonus = 0;
    		double percent1 = 0.1;
    		double percent2 = 0.075;
    		double percent3 = 0.05;
    		double percent4 = 0.03;
    		double percent5 = 0.015;
    		double percent6 = 0.01;
    
    		if (profit <= 100000) {
    			bonus = profit * percent1;
    		} else if (profit <= 200000) {
    			bonus = 100000 * percent1 + (profit - 100000) * percent2;
    		} else if (profit <= 400000) {
    			bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (profit - 200000) * percent3;
    		} else if (profit <= 600000) {
    			bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (400000 - 200000) * percent3
    					+ (profit - 400000) * percent4;
    		} else if (profit <= 1000000) {
    			bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (400000 - 200000) * percent3
    					+ (600000 - 400000) * percent4 + (profit - 600000) * percent5;
    		} else {
    			bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (400000 - 200000) * percent3
    					+ (600000 - 400000) * percent4 + (1000000 - 600000) * percent5 + (profit - 1000000) * percent6;
    		}
    
    		System.out.println(bonus);
    		in.close();
    	}
    }
    
  • 相关阅读:
    python课堂整理5---元组
    用python输出回文数
    python课堂整理4---列表的魔法
    python基础知识练习题一
    python课堂整理3---字符串魔法
    python课堂整理2
    python课堂整理1
    励志程序媛---从厂妹到Google年薪60W RMB程序员
    动态链接库--靠谱
    基于VS2019———C++生成自己的静态链接库————良心实战笔记
  • 原文地址:https://www.cnblogs.com/denggelin/p/11324816.html
Copyright © 2011-2022 走看看