Leap Year Calculation

The need for leap years arises from the fact that the time taken by the earth to orbit the sun (the year) is not an exact number of days - the length of the day being determined by the spin of the earth. This incompatibility is somewhat inconvenient for calendar making, causing it to be more complex.

The exact length of the year (i.e. the revolution of the earth around the sun) is 365.24219 days. If we had a calendar with years having only 365 days then the seasons (which are determined by the rotation of the earth around the sun) would drift by a quarter of a day in every year. This might seem small, but after 100 years the seasons would have drifted by 25 days and very quickly there would arise the situation where summer is occurring when winter used to!

The criteria for whether a year is a leap year is that it is divisible by 4 and not divisible by 100.  But, years that are divisible by 400 are leap years.  Therefore the year 1900 was not a leap year because it is divisible by 100, but the year 2000 was a leap year because it is divisible by 400.

 

Write a program that reads in a list of 10 years and determines which ones are leap years and which ones are not.  Each year will appear on a separate line.

View - Sample Data File