Java利用switch输入月份输出季节(判断季节)
作者:互联网
import java.util.Scanner;
class season{ //记得修改文件名
public static void main(String[] args){
int month=0;
System.out.println("请您输入日期:");
Scanner sc=new Scanner(System.in);
month=sc.nextInt();
switch (month)
{
case 12:
case 1:
case 2:
System.out.println("该月份为冬季");
break;
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;
default:
System.out.println("您输入的月份不正确!!!");
break;
}
}
}
标签:case,Java,季节,System,month,break,switch,println,out 来源: https://blog.csdn.net/qq_63108921/article/details/122015643