Answer:
Explanation:
The following code is written in Java and uses a series of IF statements and remainder operator (%) to calculate whether or not a year is a Leap Year. If so it is added to the ArrayList of leapYears, If not then it is skipped. Finally, the ArrayList is printed out to the terminal.
public static void leapYear() {
ArrayList<Integer> leapYears = new ArrayList();
for (int i = 1800; i <= 2020; i++) {
if ((i % 4) == 0) {
if ((i % 100) == 0) {
if ((i % 400) == 0) {
leapYears.add(i);
}
} else {
leapYears.add(i);
}
}
}
for (int x : leapYears) {
System.out.println(x);
}
}