3 回答
TA贡献1817条经验 获得超6个赞
约定类名中的所有FIRTS图表的首字母都需要大写,而代码的结构我认为应该是这样的
public class RollerCoaster {
static int age = 11;
static int weight = 81;
public static void main(String args[]) {
if(age <= 10) {
if(weight < 10) {
System.out.println("This person needs to ride the black roller coaster.");
}else if(weight >= 80 && weight <= 200) {
System.out.println("This person needs to ride the red roller coaster.");
}else {
System.out.println("The roller coaster is not able for this person");
}
}else{
if(weight < 10) {
System.out.println("This person needs to ride the black roller coaster.");
}else if(weight >= 80 && weight <= 200) {
System.out.println("This person needs to ride the red roller coaster.");
}else {
System.out.println("The roller coaster is not able for this person");
}
}
}
}
TA贡献1776条经验 获得超12个赞
对于关系运算符 '<=' 您需要提供两个操作数。所以你else if
在你的 if 语句中应该是:
else if ( age <= 10 && weight >= 80 && weight <= 200 ) { }
添加回答
举报