-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleapyear.java
More file actions
36 lines (33 loc) · 724 Bytes
/
Copy pathleapyear.java
File metadata and controls
36 lines (33 loc) · 724 Bytes
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
34
35
36
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
int year =s.nextInt();
boolean leap = false;
if (year % 4 == 0)
{
// if the year is century
if (year % 100 == 0)
{
// if year is divided by 400
// then it is a leap year
if (year % 400 == 0)
leap = true;
else
leap = false;
}
// if the year is not century
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.");
}
}