我不确定if语句中的错误在哪里,感谢任何帮助。
import java.util.Scanner; 公共课练习4P94 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int carNum;
boolean chck;
do {
chck = true;
System.out.println("Enter the Car Model Number: ");
carNum = input.nextInt();
if (carNum == 119 || carNum == 179 || carNum >== 189 && carNum <== 195 || carNum == 221 || carNum == 780){
System.out.println("Your car is defective and must be repaired");
} else if (!(carNum == 119 || carNum == 179 || carNum >= 189 && carNum <= 195 || carNum == 221 || carNum == 780)){
System.out.println("Your car is not defective");
} else {
System.out.println("Please enter a valid car model number");
chck = false;
}
} while (chck);
}
}
答案 0 :(得分:0)
在大于/小于标志
之后,你不需要两个等号 carNum >= 189 && carNum <= 195