Java-用switch判断季节
作者:互联网
import java.util.Scanner;
public class test03 {
/**
* 判断四季
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
System.out.println("请输入月份:");
int yf = scanner.nextInt();
switch (yf) {
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;
}
}
}
标签:case,Java,Scanner,季节,System,break,switch,println,out 来源: https://www.cnblogs.com/itszx/p/15611837.html