/**
根据键盘录入的月份,输出该月份所对应的季节
*/
import java.util.Scanner;
class Season
{
public static void main(String[] args)
{ //封装键盘录入
Scanner season=new Scanner(System.in);
//提示输入
System.out.println("请输入月份(1-12):");
//调包
int number=season.nextInt();
if (number==1||number==2||number==12)
{
System.out.println("冬季");
}
else if(number==3||number==4||number==5)
{
System.out.println("春季");
}
else if(number==6||number==7||number==8)
{
System.out.println("夏季");
}
else if(number==9||number==10||number==11)
{
System.out.println("秋季");
}
else
{
System.out.println("月份有误");
}
if (number>=1&&number<=6)
{
System.out.println("上半年");
}
else if (number>=7&&number<=12)
{
System.out.println("下半年");
}
else
{
System.out.println("月份有误");
}
}
}
|