-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathQ7_leap_year.java
28 lines (24 loc) · 1014 Bytes
/
Q7_leap_year.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
// Q7. Input a year and find whether it is a leap year or not.
//To know about leap year go to: https://learn.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-
package JAVA_Lab_File;
import java.util.Scanner;
public class Q7_leap_year {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a year, to check if it's a leap year or not: ");
int year = input.nextInt();
if (year%4 == 0) {
if (year%100 == 0) {
if(year%400 == 0) {
System.out.println("The given year "+ year + " is a leap year.");
} else {
System.out.println("The given year "+ year + " is not a leap year.");
}
} else {
System.out.println("The given year "+ year + " is a leap year.");
}
} else {
System.out.println("The given year "+ year + " is not a leap year.");
}
}
}