Guest User

Untitled

a guest
Feb 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. /* 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.
  2.  
  3. You must use the method header outlined in the question. Failure to do so will result in an immediate 25% deduction of your grade.
  4.  
  5. FileName: IsLeapYear_LastName.java */
  6.  
  7.  
  8. import java.util.Scanner;
  9. public class IsLeapYear_beerens {
  10.     static Scanner reader = new Scanner(System.in);
  11.     public static void main(String[] args)
  12.     {
  13.         System.out.print("Current Year: ");
  14.         System.out.print("Leap Year: " + (isLeapYear(reader.nextInt())));
  15.     }
  16.     public static boolean isLeapYear(int year)
  17.     {
  18.         return  (   ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) );
  19.     }
  20. }
Add Comment
Please, Sign In to add comment