代码如下
public class Test {
public static void main(String[] args) {
int age=70;
if(age>=0&&age<=18) {
System.out.print(“是少年”);
}else if (age>=19&&age<=28){
System.out.print(“是青年”);
}else if(age>=29&&age<=55){
System.out.print(“是中年”);
}else if (age>=56){
System.out.print(“是老年”);
}else{
System.out.print(“年龄输入有误”);
}
}
}
运行结果