View Code of Problem 28

import java.util.Scanner;

class Main{
  
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int a = scanner.nextInt();
            //rs.add(judge(a) ? "Leap Year" : "Not Leap Year");
            System.out.println(judge(a) ? "Leap Year" : "Not Leap Year");
        }
    }
    
    public static boolean judge(int a){
        if (a % 100 == 0) {
            return a % 400 == 0;
        } else {
            return a % 4 == 0;
        }
    }
}

Double click to view unformatted code.


Back to problem 28