Leap year

A leap year is a calendar year that includes an additional day to synchronize the calendar year with the astronomical or seasonal year. – Wikipedia

Logic

The Logic to check this is quite simple. We only need to check if the given year is multiple of 4 or 400, but it should not be multiple of 100.

Program

import java.util.Scanner;

public class LeapYear {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);

        System.out.println("Enter a year : ");
        int year = scanner.nextInt();

        if (year % 4 == 0) {

            if (year % 100 == 0) {

                if (year % 400 == 0) {
                    System.out.println(year + " is a leap year.");
                } else {
                    System.out.println(year + " is not a leap year.");
                }
                    
            } else {
                System.out.println(year + " is a leap year.");
            }

        } else {
            System.out.println(year + " is not a leap year.");
        }

    }

}

Output

Enter a year : 2012
2012 is a leap year.