Sat Sep 11 2021
Leap Year
Java Programming1030 views
File Name: leap-year.java
import java.io.*;
import java.util.Scanner;
class leap {
/* Constructor */
leap(int yr) {
if(yr % 4 == 0 || yr % 400 == 0)
System.out.println("It's a Leap Year!");
else
System.out.println("It's not a Leap Year!");
}
}
class leap_year {
public static void main(String args[ ]) {
int year;
/* Create object of 'Scanner' to received data from user */
Scanner input = new Scanner(System.in);
System.out.println("Enter a Year:");
year = Integer.parseInt(input.nextLine());
leap ly = new leap(year);
}
}
/* Output */
Enter a Year:
2004
It's a Leap Year!
/* ------------------------- */
Enter a Year:
1999
It's not a Leap Year!
Reference:
Author:Geekboots