A leap year has 366 days, as opposed to a common year, which has 365. Nearly every 4 years is a Leap Year, and we add a Leap Day, an extra – or intercalary – day on February 29.
Leap Years are needed to keep our modern day Gregorian Calendar in alignment with the Earth’s revolutions around the sun. It takes the Earth approximately 365.242199 days – or 365 days, 5 hours, 48 minutes, and 46 seconds – to circle once around the Sun. This is called a tropical year.
However, the Gregorian calendar has only 365 days in a year, so if we didn’t add a day on February 29 nearly every 4 years, we would lose almost six hours off our calendar every year. After only 100 years, our calendar would be off by approximately 24 days!
In the Gregorian calendar 3 criteria must be taken into account to identify leap years:
- The year is evenly divisible by 4;
- If the year can be evenly divided by 100, it is NOT a leap year, unless;
- The year is also evenly divisible by 400. Then it is a leap year.
This means that 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.
The year 2000 was somewhat special as it was the first instance when the third criterion was used in most parts of the world since the transition from the Julian to the Gregorian Calendar.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import java.io.*; public class Leap { public static void main(String args[])throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int y; System.out.println("Enter a year: "); y = Integer.parseInt(br.readLine()); if(y%4==0 && y%100!=0 || y%400==0) System.out.println("The year is a leap year"); else System.out.println("The year is not a leap year"); } } |
Leave a Reply