Sunday 1 November 2015

Determine If Year Is Leap Year



Leap Year:- In simple words ,Leap year is a year which are multiple of 4.It is also known as intercalary year or bissextile year.

Input:- 2004

Output:- Its a Leap year.


Sample Program:-


 /**  
  * @author Dixit  
  *  
  */  
 public class LeapYear {  
      /**  
       * @param args  
       */  
      public static void main(String[] args) {  
           //year we want to check  
           int year = 2004;  
           //if year is divisible by 4, it is a leap year  
           if((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))  
           System.out.println("Year " + year + " is a leap year");  
           else  
           System.out.println("Year " + year + " is not a leap year");  
      }  
 }  



 Output  
 Year 2004 is a leap year  


Enjoy Programming

No comments:

Post a Comment