Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a boolean method isLeapYear(int year) that returns true if year is a leap year and false otherwise. A leap year is a year that is evenly divisble by 4 and either is not divisble by 100 or is divisible by 400. For example, 2000 and 2004 are leap years, but 2003 and 2100 are not.
- You must use the method header outlined in the question. Failure to do so will result in an immediate 25% deduction of your grade.
- FileName: IsLeapYear_LastName.java */
- import java.util.Scanner;
- public class IsLeapYear_beerens {
- static Scanner reader = new Scanner(System.in);
- public static void main(String[] args)
- {
- System.out.print("Current Year: ");
- System.out.print("Leap Year: " + (isLeapYear(reader.nextInt())));
- }
- public static boolean isLeapYear(int year)
- {
- return ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) );
- }
- }
Add Comment
Please, Sign In to add comment