闰年的判定规则是:
如果该年能被4整除且不能被100整除,或者能被400整除,则该年是闰年,否则不是
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println(“请输入一个年份:”);
long year = scan.nextLong();
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
System.out.println(year + “年是闰年!”);
} else {
System.out.println(year + “年是平年!”);
}
}
}