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;
}


}

}

Java-用switch判断季节

 

上一篇:Delphi - 采用第三方控件TMS、SPComm开发串口调试助手


下一篇:Day19 Switch选择结构