- import java.util.Scanner;
- class WeekDemo
- {
- private static int week;
- public static void main(String []args)
- {
- Scanner input=new Scanner(System.in);
- System.out.println("请输入月份");
- int week=input.nextInt();
- System.out.println(week);
- show();
- }
- static void show()
- {
-
- if(week<1 || week>12)
- {
- System.out.println("你所输出的不正确");
- }
- else if(week>=3 && week<=5)
- {
- System.out.println(week+"月份是春季");
- }
- else if(week>=6 && week<=8)
- {
- System.out.println(week+"月份是夏季");
- }
- else if(week>=9 && week<=11)
- {
- System.out.println(week+"月份是秋季");
- }
- else{
- System.out.println(week+"月份是冬季");
- }
- }
- }
复制代码 |