Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with making a leap year calculator in Java, the question and requirements for the code are in the images above. Write a method

image text in transcribedimage text in transcribed

Need help with making a leap year calculator in Java, the question and requirements for the code are in the images above.

Write a method isLeapYear with a parameter of type int named year. The parameter needs to be greater than or equal to 1 and less than or equal to 9999. If the parameter is not in that range return false. Otherwise, if it is in the valid range, calculate if the year is a leap year and return true if it is a leap year, otherwise return false. To determine whether a year is a leap year, follow these steps: 1. If the year is evenly divisible by 4 , go to step 2. Otherwise, go to step 5 . 2. If the year is evenly divisible by 100 , go to step 3 . Otherwise, go to step 4 . 3. If the year is evenly divisible by 400 , go to step 4. Otherwise, go to step 5. 4. The year is a leap year (it has 366 days). The method isLeapYear needs to return true. 5. The year is not a leap year (it has 365 days). The method isLeapYear needs to return false. The following years are not leap years: 1700,1800,1900,2100,2200,2300,2500,2600 This is because they are evenly divisible by 100 but not by 400 . The following years are leap years: 1600,2000,2400 Examples of input/output: - IsLeapYear(-1600): should return false since the parameter is not in range (1-9999) - isLeap Year(1600); should return true since 1600 is a leap year - IsLeap Year(2017); should return false since 2017 is not a leap year - isLeapYear(2000); should return true because 2000 is a leap year NOTE: The method isLeapYear needs to be defined as public static like we have been doing so fat in the course. NOTE: Do not add a main method to solution code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago