-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeapYear.java
More file actions
32 lines (24 loc) · 753 Bytes
/
LeapYear.java
File metadata and controls
32 lines (24 loc) · 753 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
package CodingPractice;
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args) {
// Check if a input year is leap or not
Scanner sc = new Scanner(System.in);
System.out.println("Enter a year : ");
int year = sc.nextInt();
String result;
// Technique 01 - If else
if (year % 4 == 0)
if (year % 100 == 0)
if (year % 400 == 0)
result = "Leap Year";
else
result = "Not a Leap Year";
else
result = "Leap Year";
else
result = "Not a Leap Year";
System.out.println(year + " is " + result);
sc.close();
}
}