你好,我叫Demo,今年两岁。刚刚学会辨别你是老年人,中年人,青年人还是小屁孩。不信请输入你的年龄:
public class Demo {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入你的年龄:");
int age = input.nextInt();
if(age > 60) {
System.out.println("哇,你原来是老年人。");
}else if(age > 40) {
System.out.println("哇,你原来是中年人。");
}else if(age > 20) {
System.out.println("哇,你原来是青年人。");
}else {
System.out.println("哪家的娃,别闹!");
}
}
}