Net-informations.com

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.


leap year in Java

How to determine whether a year is a leap year

  1. If it is evenly divisible by 4
  2. Unless it is also evenly divisible by 100
  3. 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.

Algorithm

  1. If year is not divisible by 4 then it is a common year
  2. Else if year is not divisible by 100 then it is a leap year
  3. Else if year is not divisible by 400 then it is a common year
  4. Else it is a leap year









net-informations.com (C) 2020    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About