-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeapYear.java
More file actions
28 lines (28 loc) · 761 Bytes
/
Copy pathLeapYear.java
File metadata and controls
28 lines (28 loc) · 761 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
import java.util.Scanner;
public class LeapYear {
static boolean isLeapYear (int year) {
if(year%4 == 0){
if(year%100 == 0 && year%400 != 0){
return false;
}
else{
return true;
}
}
else{
return false;
}
}
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter a year:");
int y = sc.nextInt();
boolean isYear = isLeapYear(y);
if (isYear){
System.out.println("The year " + y + " is a leap year.");
} else{
System.out.println("The year " + y + " is not a leap year.");
}
sc.close();
}
}