-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram11_LeapYear.java
More file actions
27 lines (25 loc) · 896 Bytes
/
Program11_LeapYear.java
File metadata and controls
27 lines (25 loc) · 896 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
// Write a Java program that takes a year from the user and prints whether it is a leap year or not.
// Date : 27/12/2023, Author : Yash Wadhvani
import java.util.Scanner;
public class Program11_LeapYear {
public static void main(String[] args) {
int year;
try (Scanner sc = new Scanner(System.in)) {
System.out.println("Enter a Year :-");
year = sc.nextInt();
}
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) {
System.out.println(year + " Is a Leap Year.");
} else {
System.out.println(year + " Is a Not Leap Year.");
}
} else {
System.out.println(year + " Is a Leap Year.");
}
} else {
System.out.println(year + " Is a Not Leap Year.");
}
}
}