解题思路:根据if···else···if多选一进行冗余计算
注意事项:有些麻烦,容易理解
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int profit=scanner.nextInt();
int sum;
if(profit<=100000){sum=(int)(profit*0.10);System.out.println(sum);}
else if(profit<=200000){sum=(int)(10000+(profit-100000)*0.075);System.out.println(sum);}
else if(profit<=400000){sum=(int)(10000+7500+(profit-200000)*0.05);System.out.println(sum);}
else if(profit<=600000){sum=(int)(10000+7500+10000+(profit-400000)*0.03);System.out.println(sum);}
else if(profit<=1000000){sum=(int)(1000+7500+10000+6000+(profit-600000)*0.015);System.out.println(sum);}
else{sum=(int)(profit*0.01);}
}
}
0.0分
2 人评分