/*
需求: 接受鍵盤錄入一個月份, 根據對應的月份輸出對應的季節。
345 春天
678 夏天
9 10 11 秋天
1 2 12 冬天
要求使用switch語句實現。
*/
import java.util.*;
class Demo4
{
public static void main(String[] args)
{
System.out.println("請輸入一個月份:");
//創建一個掃描器
Scanner scanner = new Scanner(System.in);
//調用掃描器的nextInt方法
int month = scanner.nextInt();
switch(month){
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;
case 12:
case 1:
case 2:
System.out.println("冬天");
break;
default:
System.out.println("沒有對應的季節");
break;
}
}
}