判断输入的年份是闰年还是平年!!!

package com.hp.cn1;

import java.util.Scanner;

//年份能被4整除闰年
//年份能被100整除不是闰年
//年份能被400整除闰年
public class Task2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("---->请输入年份");
        int year  = sc.nextInt();
        System.out.println("你输入的年份是"+year);
        
        if(year % 100 == 0) {
            if(year % 400 == 0) {
                System.out.println(year + "是闰年");
            }else {
                System.out.println(year + "不是闰年");
            }
        }else {
            if(year % 4 == 0) {
                System.out.println(year + "是闰年");
            }else {
                System.out.println(year + "不是闰年");
            }
        }
    }
}

原文地址:https://www.cnblogs.com/wjwz/p/14131861.html