基础练习 闰年判断

image.png
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        if(ifYear(sc.nextInt())){
            System.out.println("yes");
        }else {
            System.out.println("no");
        }

    }
    static boolean ifYear(int year){
        if(year > 100 && year%4==0 && year%100!=0){
            return true;
        }
        if(year>400 && year%400==0){
            return true;
        }
        return false;
    }
}

你可能感兴趣的:(基础练习 闰年判断)