forked from Rupangkan/itssubhamroy.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
38 lines (29 loc) · 778 Bytes
/
Copy pathMain.java
File metadata and controls
38 lines (29 loc) · 778 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
37
38
//java prohram to display a year is leap year or not
public class Main {
public static void main(String[] args) {
// Enter the year you want to check
int year = 2012;
boolean leap = false;
// checking if the year is divided by 4
if (year % 4 == 0) {
// checking if the year is century
if (year % 100 == 0) {
// if it is divided by 400
// then it is a leap year
if (year % 400 == 0)
leap = true;
else
leap = false;
}
// checking 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.");
}
}