Java利用switch输入月份输出季节(判断季节)

Java利用switch输入月份输出季节(判断季节)

import java.util.Scanner;
class season{            //记得修改文件名
	public static void main(String[] args){
		int month=0;
		System.out.println("请您输入日期:");
		Scanner sc=new Scanner(System.in);
		month=sc.nextInt();
		switch (month)
		{
		case 12:
		case 1:
		case 2:
			System.out.println("该月份为冬季");
			break;
		case 3:
		case 4:
		case 5:
			System.out.println("该月份为春季");
			break;
		case 6:
		case 7:
		case 8:
			System.out.println("该月份为夏季");
			break;
		case 9:
		case 10:
		case 11:
			System.out.println("该月份为秋季");
			break;
		default:
			System.out.println("您输入的月份不正确!!!");
			break;
		}
}
}

 

上一篇:CF901C Bipartite Segments


下一篇:D1. Too Many Segments (easy version贪心)