输入一个月份查询对应的季节,代码如下所示:
package three;

import java.util.Scanner;

public class siji {
public static void main(String[] args) {
int month;
Scanner scanner=new Scanner(System.in);
System.out.println(“请你输入需要查询的月份:”);
month=scanner.nextInt();
if(month<1 || month>12) {
System.out.println(“输入的月份错误!!!”);
}
else if(month>=3 && month<=5) {
System.out.println(month+“月是春季”);
}
else if(month>=6 && month<=8) {
System.out.println(month+“月是夏季”);
}
else if(month>=9 && month<=11) {
System.out.println(month+“月是秋季”);
}else {
System.out.println(month+“月是冬季”);
}
}

}
代码运行结果如下图所示:
输入月份查询对应的季节

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-06
  • 2021-12-12
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2021-07-10
  • 2021-10-21
  • 2021-07-12
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-01-17
相关资源
相似解决方案