If多选择结构


 

 1 package com.stx.zx;
 2 
 3 import java.util.Scanner;
 4 
 5 public class If02 {
 6     public static void main ( String[] args ) {   //主方法
 7         Scanner in = new Scanner(System.in);  //,准备从键盘接收数据
 8         System.out.println("请输入月份:");
 9         int month = in.nextInt();  //等待数据输入
10 
11         if (month>=3&&month<=5){
12             System.out.println("春季");
13         }else if (month>=6&&month<=8){
14                 System.out.println("夏季");
15             }else if (month>=9&&month<=11){
16                     System.out.println("秋季");
17                 }else if(month ==1 || month == 2|| month == 12){
18                         System.out.println("冬季");
19                     }else
20             System.out.println("输入错误");
21 
22         in.close();
23     }
24 }

 

posted @ 2022-02-24 11:14  VVMgAI  阅读(31)  评论(0)    收藏  举报