我试图在此代码中插入“if”语句,但它不能很好地工作。其固定工资和奖励(37.28 * 1.32)将给予94,261.02一次。低于94,261.02只是一个普通的37.28佣金。所有iny“int”行用红色加下划线显示!分数。所以我试图找出问题:如何使用“if”语句
System.out.println("Enter your annual sales");
String annual = input.nextLine();
int salary = 7550281;
int commission = 38_28;
int compensation = Integer.parseInt(annual) * commission + salary;
System.out.println("compensation is: "+compensation);
if (Integer.parseInt(annual) < 92416_02) {
int salary = 7550281;
int commission = 37_28 * 1_32;
int compensation = Integer.parseInt(annual) * commission + salary;
System.out.println("compensation is: "+compensation);
} else if (Integer.parseInt(annual) > 92416_02){
int salary = 7550281;
int commission = 38_28;
int compensation = Integer.parseInt(annual) * commission + salary;
System.out.println("compensation is: "+compensation);
}
谢谢。
@MadProgrammer Java 1.7允许在数值中使用_,以获得更好的表示/可读性。 – Batty
自编译器版本“1.6”以来我们不支持使用'_'的数字,现在我们就像'7' ... –
@Batty严重吗?这使得更好的介绍:P – MadProgrammer