你,请输入年龄?

你好,我叫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("哪家的娃,别闹!");
    	  }	  
      }
}

在这里插入图片描述

发布了5 篇原创文章 · 获赞 3 · 访问量 243

猜你喜欢

转载自blog.csdn.net/qq_40924992/article/details/105060304