Java Program to Check Leap Year
What is a Leap Year?
It takes approximately 365.25 days for Earth to orbit the Sun (a solar year). We usually round the days in a calendar year to 365. To make up for the missing partial day, we add one day to our calendar approximately every four years . This mean that, a year containing an extra day. It has 366 days instead of the normal 365 days. That is a leap year. The extra day is added in February, which has 29 days instead of the normal 28 days.
How to determine whether a year is a leap year
- If it is evenly divisible by 4
- Unless it is also evenly divisible by 100
- Unless it is also evenly divisible by 400
The year 2000 was a leap year, because it obeys all three rules 1, 2, and 3, and therefore was a leap year.
- If year is not divisible by 4 then it is a common year
- Else if year is not divisible by 100 then it is a leap year
- Else if year is not divisible by 400 then it is a common year
- Else it is a leap year