Day 2: Leap Years
Exercise
Write a Java program to determine if a given year is a leap year.
Introduction
A year is a leap year if it conforms to either of the following conditions:
- It is divisible by 400
- It is divisible by 4 but not divisible by 100
Algorithm
- Implement the core functionality using a text-based interface for I/O.
- Build a GUI to wrap your implementation.
Resources
Hints
Use the modulo (%) operator to determine if a number is evenly divisible by another value. For example:
12 % 3
42 % 10
The first line is equal to 0 since 12 is evenly divisible by 3. The second line is equal to 2 because the remainder of 42 / 10 is 2.