Java Program to check Leap Year.


//program to check leap year
public class checkLeapYear
{
  static boolean checkYear(int year)
  {
     if (year%400 == 0)
        return true;

     if(year%100 == 0)
        return false;
    
     if(year%4 == 0)
        return true;
        return false;
}
 public static void main(String args[])
{
  int year = 2001;
  System.out.print(checkYear(2001)? "Leap Year" : "Not a Leap Year");
}
}

Previous Post Next Post

Contact Form