Be the first user to complete this post

  • 0
Add to List
Beginner

306. Determine if Given Year is Leap Year

Objective: Given a Year, write a java program to find whether year is leap year or not.

Leap Year: a year, usually occurring once every four years, that has 366 days including February 29 as an intercalary day, called Leap Year.

Example:

Year: 2004, 2008, 2012 are Leap years.
Year: 1993, 2001, 2003 are not leap years.

Approach:

Pseudo code:

if (year is not divisible by 4) then
    (its not a leap year)
else if (year is not divisible by 100) then
    (its a leap year)
else if (year is not divisible by 400) then
    (its not a leap year)
else (it is a leap year)

Output:

Given year 1992 is leap year
Given year 2000 is leap year
Given year 2001 is not leap year, its a common year
Given year 2002 is not leap year, its a common year
Given year 2004 is leap year