Leap Year Or Not Example Java Program


A leap year (also known as an intercalary year or a bissextile year) is a year containing one additional day (or, in the case of lunisolar calendars, a month) in order to keep the calendar year synchronized with the astronomical or seasonal year.[1] Because seasons and astronomical events do not repeat in a whole number of days, calendars that have the same number of days in each year, over time, drift with respect to the event that the year is supposed to track.


	The remainder of "year/4" should be equal to zero for a leap year.

Leap Year Or Not Example Program

import java.util.Scanner;
public class LeapYearOrNot {
    public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		System.out.print("Enter the year in the format yyyy.\nYEAR= ");
		int year=in.nextInt();
        if (year % 4 == 0) {
            System.out.println(year + " is a leap year");
		else {
            System.out.println(year + " is not a leap year");

Sample Output

Output is:
Enter the year in the format yyyy.
YEAR= 1944
1944 is a leap year