Loading...
Loading...
A calendar app must know whether February has 29 days. A year is a leap year if it is divisible by 4, except century years (divisible by 100), which are leap years only if they are also divisible by 400. So 2024 and 2000 are leap years, but 1900 is not.
Read a year and print Leap year or Not a leap year.
Leap year or Not a leap year.Example 1
Input
2024
Output
Leap year
Divisible by 4 and not a century year.
Example 2
Input
1900
Output
Not a leap year
A century year not divisible by 400.
Example 3
Input
2000
Output
Leap year
A century year divisible by 400.
Try the problem first. Open one hint at a time.
Check the rules from the most special to the most general: 400 first, then 100, then 4.
In one expression: divisible by 4 and not by 100, or divisible by 400.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor