java实现输入月份打印季节

java实现输入月份打印季节

import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        /*
        * 输入月份打印季节
        * 12 1 2冬季
        * 3 4 5春季
        * 6 7 8夏季
        * 9 10 11秋季
        * */
        System.out.print("请输入月份:");
        Scanner scan = new Scanner(System.in);
        int month = scan.nextInt();
        switch (month/3){
            case 0:
                System.out.println("冬天");
                break;
            case 1:
                System.out.println("春天");
                break;
            case 2:
                System.out.println("夏天");
                break;
            default:
                System.out.println("秋天");
        }
    }
}

你可能感兴趣的:(随笔)