怎么用Java实现下面图片

 

这个用一个if else 就能解决。

Double ticheng = 0;
Double money = 0;
if(money >= 1 && money <= 5000){
    ticheng += money * 0.08;
}else if(money >= 5001 && money <= 10000){
     ticheng += 5000* 0.08; 
     ticheng += (money-5000) * 0.10;
}else if(money >= 10001){
     ticheng += 5000* 0.08; 
     ticheng += 5000* 0.10; 
     ticheng += (money-10000) * 0.12;
}

 

用if,else if分段计算就可以了。

import java.util.*;
public class Test{
    public static void main(String[] args){
        float salary,tax=0;
        Scanner in = new Scanner(System.in);
        System.out.println("请输入您的销售额:");
        salary = in.nextFloat();
        if(salary<=5000){
    	    tax=salary*0.08;
        }else if(salary>3500 && salary<=5000){
            tax=5000*0.08;
    	    tax +=(salary-5000)*0.1;
        }else{
    	    tax=5000*0.08;
    	    tax +=(salary-5000)*0.1;
    	    tax += (salary-10000)*0.12;
        }
        System.out.println("你销售提成是:"+tax);
    
    }
}

 

您的问题已经有小伙伴解答了,请点击【采纳】按钮,采纳帮您提供解决思路的答案,给回答的人一些鼓励哦~~

ps:开通问答VIP,享受5次/月 有问必答服务,了解详情↓↓↓

【电脑端】戳>>>  https://vip.csdn.net/askvip?utm_source=1146287632
【APP 】  戳>>>  https://mall.csdn.net/item/52471?utm_source=1146287632