This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 4: Applying your knowledge

Leap year validator

face Josiah Wang

Time to up the game!

Write a program that checks whether a year entered by the user is a leap year.

Remember that just because a year can be divided by four does not necessarily mean that it is a leap year! Here is a description of how to determine whether a year is leap year, taken from Wikipedia:

Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the years 1600 and 2000 are.

🤯🤯🤯

Remember to test all edge cases!

Sample run #1

Please enter year: 2021
Not a leap year

Sample run #2

Please enter year: 2020
Leap year

Sample run #3

Please enter year: 1990
Not a leap year

Sample run #4

Please enter year: 2000
Leap year

Sample run #5

Please enter year: 1800
Not a leap year