Question: In Java 2. Develop a method for determining if a given year is a leap year. The year in question should be passed as a
In Java
2. Develop a method for determining if a given year is a leap year. The year in question should be passed as a parameter to the method. The method should return a Boolean indicator as to whether or not the given year is a leap year How to determine if a given year is a leap year: Any year that is not divisible by 4 is not a leap year. A year that is divisible by 4 is most likely a leap year. The exception are years that occur at the turn of a century. These years can be easily identified since they are divisible by 100. For these years, they are leap years only if the year is divisible by 400 The main method should gather the year from the end user, call the leap year method to retrieve a Boolean result, and display a descriptive message as to whether or not the year is a leap year. Hint: Modulo arithmetic can be used to determine the remainder after dividing one integer by another. The modulus operator is %. For example, the following statement assigns the value 3 to the variable leftover, since 15 divided by 6 results in a quotient of 2 and a remainder of 3 leftover-15 % 6; In the statement below, 15 is divisible by 5 since 15 mod 5 evaluates to O leftovers 15 % 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
