Is it a leap year?
In 1582 the Gregorian calendar was introduced. Our planet takes approximately 365.25 days to orbit the sun once. It's that .25 that creates the need for a leap year every four years. During non-leap years (common years) the calendar doesn't take into account the extra quarter of a day required by Earth to complete a single orbit. In leap years there are 29 days in February instead of 28.
Write a program to say whether the year entered by a user is a leap year or not. Any year exactly divisible by four is usually a leap year unless it is also divisible by one hundred. The exception is that all years divisible by four hundred are always leap years.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
Enter a year: 1900
1900 is not a leap year.
Enter a year: 2000
2000 is a leap year.
Enter a year: 2022
2022 is not a leap year.
Enter a year: 2024
2024 is a leap year.
Use these resources as a reference to help you meet the success criteria.
Run the unit tests below to check that your program has met the success criteria.
Enter a year: 1900
1900 is not a leap year.
Enter a year: 2000
2000 is a leap year.
Enter a year: 2026
2026 is not a leap year.
Enter a year: 2028
2028 is a leap year.
Check that you have: