Java Function to determine whether the year is a leap year or not.Any year is entered through the keyboard.

//Java Function to determine whether the year is a leap year or not.Any year is entered through the keyboard.



import java.util.Scanner;

public class Program 
{   
    	public static void main( String[] args ) 
    	{
		Scanner reader = new Scanner(System.in);
		int year,leap;
		System.out.print("\nEnter an year : ");
		year = reader.nextInt();
		leap=find(year);
		if(leap==1)
			System.out.print("\n"+ year +" year is leap year ");
		else	
			System.out.print("\n"+ year +" year is not a leap year ");
   	}
  	public static int find(int a)
   	{
		
    		int i=0;
		if((a % 4 & a % 100 & a % 400)==0)
			i=1;
		else
			i=0;
		return i;
   	}
	
}

Output :
Enter an year : 2016

2016 year is leap year



Leave a comment