Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A year in the modern Gregorian Calendar consists of 3 6 5 days. In reality, the earth takes longer to rotate around the sun. To

A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun.
To account for the difference in time, every 4 years, a leap year takes place.
A leap year is when a year has 366 days: an extra day, February 29th.
The requirements for a given year to be a leap year are:
The year must be divisible by 4
If the year is a century year (1700,1800, etc.), the year must be evenly divisible by 400
Some example leap years are 1600,1712, and 2016(but not 1700 and 1801).
This program will again determine whether a year is a leap year, but will use a method to make the determination this time.
Start with the supplied template code, editing the top of program comment to include your FULL NAME.
(1)
Fill in the method definition for the isLeapYear() method (below the main() method in the template).
The isLeapYear() method takes a year as a parameter
and returns a boolean set to the correct value for that year (true or false).
There should be no output displayed from the isLeapYear() method
Note that per the Coding Standards: Every method should converge on one return statement.
Therefore, this method should not be implemented with multiple return statements.
(2)
Modify the main() method to call the isLeapYear() method
and use the returned value in a decision statement to display the result as:
1954 is not a leap year
or
2016 is a leap year
NOTE: The last test is a Unit Test, which will test that your isLeapYear() method was defined correctly. JAVA
import java.util.Scanner;
public class LeapYearFinder {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
int inputYear;
System.out.println("Enter a 4-digit year:");
inputYear = scnr.nextInt();
if (isLeapYearFinder(inputYear)){
System.out.println(inputYear +" is a leap year.");
} else {
System.out.println(inputYear +" is not a leap year.");
}
scanner.close();
}
/**
* Method to determine whether a year is a leap year or not
*
* @param year -4-digit year to test
* @return - boolean that is set to true if year is a leap year (or set to false otherwise)
*/
public static boolean isLeapYear (/* Add parameter */){
/* Add the isLeapYear() method code here */
}
}

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

=1 Homework C2S5 Question 4 of 10 (1 1 2 Determine the vertical as

Answered: 1 week ago