类名 JudgeLeapYear
类代码
import java.util.Scanner;
public class JudgeLeapYear {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("请输入当前年份!");
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
if (year % 4 == 0 && year % 400 != 0) {
System.out.println("" + year + "年是闰年!");
} else if (year % 400 == 0) {
System.out.println("" + year + "年是闰年!");
} else {
System.out.println("" + year + "年不是闰年!");
}
}
}
运行结果
请输入当前年份!
2020
2020年是闰年!