1.用户输入月份 打印月份对应的季节
import java.util.*;
class YueFen
{
public static void main(String[] args)
{
Scanner input =new Scanner(System.in);
System.out.println("请输入1-12的月份");
int month=input.nextInt();
if(month==1 || month==2 || month==12)
{
System.out.println("冬季");
}else if(month==5 || month==3 || month==4){
System.out.println("春季");
}else if(month==8 || month==6 || month==7){
System.out.println("夏季");
}else if(month==11 || month==9 || month==10){
System.out.println("秋季");
}else{
System.out.println("输入月份错误!");
}
}
}
import java.util.*;
class YueFen
{
public static void main(String[] args)
{
Scanner input =new Scanner(System.in);
System.out.println("请输入1-12的月份");
int month=input.nextInt();
if(month==1 || month==2 || month==12)
{
System.out.println("冬季");
}else if(month==5 || month==3 || month==4){
System.out.println("春季");
}else if(month==8 || month==6 || month==7){
System.out.println("夏季");
}else if(month==11 || month==9 || month==10){
System.out.println("秋季");
}else{
System.out.println("输入月份错误!");
}
}
}