fighting8
2016-02-27 19:50
public class byThree{
public static void main(String[] args){
int age=(-1);
if (age>=0){
}if(age>=200){
System.out.println("外星人");
}else if (age>=120){
System.out.println("百岁老人");
}else if (age>=100){
System.out.println("老年人");
}else if (age>=60){
System.out.println("中老年人");
}else if (age>=40){
System.out.println("中年人");
}else if (age>=18){
System.out.println("成年人");
}else if(age>=12){
System.out.println("青少年");
}else{
System.out.println("少年");
}else{
System.out.println("输入错误");
}
}
}哪里错了吗,大神指教。
因为你的19行和20行都是else 只能有一个else
public class bythree{
public static void main(String[] args){
int age=(-1);
if (age>=0){
if(age>=200){
System.out.println("外星人");
}else if (age>=120){
System.out.println("百岁老人");
}else if (age>=100){
System.out.println("老年人");
}else if (age>=60){
System.out.println("中老年人");
}else if (age>=40){
System.out.println("中年人");
}else if (age>=18){
System.out.println("成年人");
}else if(age>=12){
System.out.println("青少年");
}else{
System.out.println("少年");
}
} else{
System.out.println("输入错误");
}
}
}
大括号错了
1、第五行第一个“{”要删掉
Java入门第一季(IDEA工具)
1168087 学习 · 18754 问题
相似问题