COM110 Spring 2022

Homework exercise 4

Due Tues, Feb 15

Finish the leap year program we started in class. Recall that the prompt from class read:

• Write a module to decide if a given year is a leap year. Input the year, output whether it is a leap year.

–
A ** leap year **is any year evenly
divisible by 4 but not by 100, with one exception: if it is divisible by 400 it is always a leap
year.

– E.g.,

• 2022 is not a leap year (not divisible by 4)

• 2020 was a leap year (divisible by 4 and not by 100)

• 2100 is not a leap year (divisible by 4… but also by 100)

• 2000 was a leap year (divisible by 400)

Be sure to test all the different cases using many different input years (including the four listed above) and make sure it is always working properly.

**Hint**: to test if a number is
evenly divisible by another, you can use the mod operator %

E.g., if the condition (num % 2 == 0) is true, then it means num is divisible by 2, i.e., that num is an even number.