Java实现 输入年份月份求天数季节
package quqifanxing;
import java.util.Scanner;
public class Season {
public static void main(String[] args) {
System.out.println("Please input a year:");
Scanner sc=new Scanner(System.in);
int year=sc.nextInt();
System.out.println("Please input a month:");
Scanner scc=new Scanner(System.in);
int month=scc.nextInt();
if(year%4==0&&year%100!=0||year%400==0) {
System.out.println(year+"年闰年,有366天");
if(month==2) {
System.out.println(year+"年的"+month+"月有29天");
}
else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) {
System.out.println(year+"年的"+month+"月有31天");
}
else {
System.out.println(year+"年的"+month+"月有30天");
}
}
else {
System.out.println(year+"是平年,有365天");
if(month==2) {
System.out.println(year+"年的"+month+"月有28天");
}
else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) {
System.out.println(year+"年的"+month+"月有31天");
}
else {
System.out.println(year+"年的"+month+"月有30天");
}
}
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+"月是冬季");
}
}
}