Java program to check whether the given year is leap year or not

Java program to check whether the given year is leap year or not

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package logic;
 
import java.util.Scanner;
 
public class Leapyear 
{
	public static void main(String[] args)
	{
		int year;
 
		Scanner c=new Scanner(System.in);
		System.out.println("enter a year");
		year=c.nextInt();
 
		if(year%4==0 && year%400==0)
		{
			System.out.println("it is leap year");
		}
		else if(year%100==0)
		{
			 System.out.println("not a leap year");
		}
 
		else 
		{
			 System.out.println("it is not a leap year");
		}
 
 
 
	}
 
}

output:

1
2
3
enter a year
2016
it is not a leap year

Leave a Reply

Your email address will not be published. Required fields are marked *