zoukankan      html  css  js  c++  java
  • if语句读入一个整数,表示一个人的年龄,如果小于6岁就输出儿童,6-13岁输出少年,14-17岁输出青少年,18-35岁输出青年,36-50岁输出中年,50岁以上输出中老年

    package com.study.demo;

    import java.util.Scanner;

    import java.util.Scanner;

    /**
    *  (if语句)读入一个整数,表示一个人的年龄,
    *  如果小于6岁就输出儿童,6-13岁输出少年,
    *  14-17岁输出青少年,18-35岁输出青年,
    *  36-50岁输出中年,50岁以上输出中老年
    */

    public class Demo1 {
    public
    static void main(String [] args) {   Scanner input = new Scanner(System.in);   System.out.println("请输入年龄");   int age = input.nextInt();   if( age < 6 ) {     System.out.println("儿童");   }else if( age >= 6 && age <= 13 ) {     System.out.println("少年");   }else if( age >= 14 && age <= 17 ) {     System.out.println("青少年");   }else if( age >= 18 && age <= 35 ) {     System.out.println("青年");   }else if( age >= 36 && age < 50 ) {     System.out.println("中年");   }else if( age >= 50 ) {     System.out.println("中老年");   }   }
    }
  • 相关阅读:
    生成器,迭代器
    [LeetCode] Minimum Depth of Binary Tree
    [LeetCode] Sum Root to Leaf Numbers
    [LeetCode]Sort Colors
    [LeetCode] Remove Nth Node From End of List
    [LeetCode] Palindrome Number
    [LeetCode] Container With Most Water
    [LeetCode] Pascal's Triangle II
    [LeetCode] Path Sum
    [LeetCode] Search a 2D Matrix
  • 原文地址:https://www.cnblogs.com/dsds/p/14968434.html
Copyright © 2011-2022 走看看