Simple Interest Calculator

Easy
0.0% Acceptance

Certainly! Here's a markdown-formatted lab description that explains the required output, the mathematical calculation of leap years, and includes examples:

# Leap Year Calculator Lab ## Overview In this lab, you will implement a method named `isLeapYear` in the `Main` class. This method will determine whether a given year is a leap year. Leap years are special years that help synchronize the calendar year with the solar year. ## Leap Year Calculation A leap year is typically every fourth year. However, there are exceptions to this rule: - **Every year divisible by 4 is a leap year.** - **But, if the year can be evenly divided by 100, it is NOT a leap year, unless:** - **The year is also evenly divisible by 400. Then it is a leap year.** This means years like 2000 and 2400 are leap years, as they are divisible by 400. However, years such as 1800 and 1900 are not leap years, despite being divisible by 100, because they are not divisible by 400. ## Your Task Implement the `isLeapYear` method within the `Main` class. This method should: - Take an `int` parameter representing a year. - Return a `boolean` value: `true` if the year is a leap year, and `false` otherwise. ### Examples: 1. `isLeapYear(2000)` should return `true` because 2000 is divisible by 400. 2. `isLeapYear(1989)` should return `false` because 1989 is not divisible by 4. ## Edge Cases Make sure your method correctly handles edge cases: - Years like 2100 are not leap years, even though they are divisible by 100, because they are not divisible by 400. - Regular years that are not divisible by 4, such as 2019, should also return `false`. Good luck, and have fun with this challenge!

This lab description is designed to provide users with a clear understanding of the task, the logic behind leap years, and specific examples to guide their implementation. It explains the edge cases to ensure users handle all scenarios correctly in their code.

Challenges Information

Challenge 1: Correct Method Naming

Objective: Implement a method in the Main class named isLeapYear. The method name must match exactly.

Challenge 2: Identifying a Typical Leap Year

Objective: Ensure the isLeapYear method correctly identifies the year 2000 as a leap year.

  • Test Case: isLeapYear(2000)
  • Expected Result: The method should return true, indicating that the year 2000 is a leap year.

Challenge 3: Identifying a Common Non-Leap Year

Objective: Ensure the isLeapYear method correctly identifies the year 1989 as not a leap year.

  • Test Case: isLeapYear(1989)
  • Expected Result: The method should return false, indicating that the year 1989 is not a leap year.

Challenge 4: Identifying a Centennial Non-Leap Year

Objective: Ensure the isLeapYear method correctly identifies the year 2100 as not a leap year.

  • Test Case: isLeapYear(2100)
  • Expected Result: The method should return false, indicating that the year 2100, despite being divisible by 100, is not a leap year as it is not divisible by 400.