forked from tusharjuneja06/simplejavaprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeapYear.java
31 lines (28 loc) · 809 Bytes
/
LeapYear.java
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
import java.util.*;
public class LeapYear {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter The year : ");
int year = sc.nextInt();
boolean leap = false;
if(year % 4 == 0)
{
if( year % 100 == 0)
{
// year is divisible by 400, hence the year is a leap year
if ( year % 400 == 0)
leap = true;
else
leap = false;
}
else
leap = true;
}
else
leap = false;
if(leap)
System.out.println(year + " is a leap year.");
else
System.out.println(year + " is not a leap year.");
}
}