package Day05; import javax.security.sasl.SaslServer; import java.util.Scanner; public class switchtest01 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("请输入一个月份"); int month = input.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; } /*if(month>=1&&month<=12){ if(month == 3||month ==4 || month==5){ System.out.println(month+"是春季"); }else if(month == 6||month ==7 || month==8){ System.out.println(month+"是夏季"); }else if(month == 9||month ==10 || month==11){ System.out.println(month+"是夏季"); }else{ System.out.println(month+"是冬季"); } }else{ System.out.println("输入月份有误"); } */ } }
zuoye04
最新推荐文章于 2024-08-23 15:54:50 发布