判断闰年(Java)
package day01; import java.util.Scanner; public class leap_year { public static void main (String[] args) { System.out.println("亲输入年份,闰年输出true,否则输出false。输入 0 退出。 "); Scanner scanner1 = new Scanner(System.in); int year = scanner1.nextInt(); for(;;) { if (year == 0) { System.out.println("已退出!"); break;}; boolean isLeapYear = (year % 4 == 0 && year % 100 !=0 )||year % 400 == 0; System.out.println(isLeapYear); year = scanner1.nextInt(); } scanner1.close(); } }