zoukankan      html  css  js  c++  java
  • 定义一个变量代表月份,输出对应的季节?

    要求:(1)定义一个整数(代表月份,范围1-12)
    (2)输出该月份对应的季节
    3,4,5春季
    6,7,8夏季
    9,10,11秋季
    12,1,2冬季
    (3)演示格式如下:
    月份:3
    控制台输出:3月份是春季
    `public class Test06{
    public static void main(String[] args) {
    int month=3;

    	boolean spring=month>=3 && month<=5;
    	boolean summer=month>=6 && month<=8;
    	boolean autumn=month>=9 && month<=11;
    	boolean hibernate=month>=1 && month<=2 || month==12;
    	boolean out=month>12 || month<1;
    	
    	System.out.print(spring!=true?"":month+"月份春季");
    	System.out.print(summer!=true?"":month+"月份夏季");
    	System.out.print(autumn!=true?"":month+"月份秋季");
    	System.out.print(hibernate!=true?"":month+"月份冬季");
    	System.out.print(out!=true?"":"月份范围错误");
    }
    

    }`

  • 相关阅读:
    指数
    汉诺塔问题
    只用递归和当前的栈实现栈的逆序
    让你996的不是你的老板,而是其他愿意996的人
    luke towan
    2020-9-3
    2020-9-3
    springboot注解
    2020-9-2
    20200827
  • 原文地址:https://www.cnblogs.com/WangMengyi/p/14136864.html
Copyright © 2011-2022 走看看