java
用switch输入月份判段季节
package JavaTest;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
switch(x) {
case 1:
case 2:
case 3:
System.out.print("现在是春天");
break;
case 4:
case 5:
case 6:
System.out.print("现在是夏天");
break;
case 7:
case 8:
case 9:
System.out.print("现在是秋天");
break;
case 10:
case 11:
case 12:
System.out.print("现在是冬天");
break;
default:
System.out.printf("你家有%d月啊?",x);
}
}
}