Answered step by step
Verified Expert Solution
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 days. In reality, the earth takes longer to rotate around the sun.
To account for the difference in time, every years, a leap year takes place.
A leap year is when a year has days: an extra day, February th
The requirements for a given year to be a leap year are:
The year must be divisible by
If the year is a century year etc. the year must be evenly divisible by
Some example leap years are and but not and
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.
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.
Modify the main method to call the isLeapYear method
and use the returned value in a decision statement to display the result as:
is not a leap year
or
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 mainString args
Scanner scnr new ScannerSystemin;
int inputYear;
System.out.printlnEnter a digit year:";
inputYear scnrnextInt;
if isLeapYearFinderinputYear
System.out.printlninputYear is a leap year.";
else
System.out.printlninputYear is not a leap year.";
scanner.close;
Method to determine whether a year is a leap year or not
@param year 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started