30 lines
676 B
Java
30 lines
676 B
Java
|
import java.util.Scanner; // Import the Scanner class
|
||
|
|
||
|
class LeapYear {
|
||
|
public static void main(String[] args) {
|
||
|
Scanner sc = new Scanner(System.in);
|
||
|
int year1;
|
||
|
|
||
|
boolean flag;
|
||
|
|
||
|
System.out.println("Enter the year you want to check: ");
|
||
|
year = sc.nextInt();
|
||
|
|
||
|
if(year%4 != 0){
|
||
|
flag = false;
|
||
|
}else if(year%100 != 0){
|
||
|
flag = true;
|
||
|
}else if(year%400 != 0){
|
||
|
flag = false;
|
||
|
}else{
|
||
|
flag = true;
|
||
|
}
|
||
|
|
||
|
if(flag == false){
|
||
|
System.out.println("The year "+year+" is not a leap year.");
|
||
|
}else{
|
||
|
System.out.println("The year "+year+" is a leap year.");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|