要求输入月份,判断该月所处的季节并输出季节(假设:12、1、2 月为冬季,依次类推)

2023-11-19

public class Task_10101003_03 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("请输入月份:");
		int month = input.nextInt();
		switch (month) {
		case 12:
		case 1:
		case 2:
			System.out.println(month+"月是冬季");
			break;
		case 3:
		case 4:
		case 5:
			System.out.println(month+"月是春季");
			break;
		case 6:
		case 7:
		case 8:
			System.out.println(month+"月是夏季");
			break;
		case 9:
		case 10:
		case 11:
			System.out.println(month+"月是秋季");
			break;

		default:
			System.out.println("你的输入有误,请重新输入");
			break;
		}
	
	}
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

要求输入月份,判断该月所处的季节并输出季节(假设:12、1、2 月为冬季,依次类推) 的相关文章

随机推荐