Leap Year

Java Programming

Java Programming Examples

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!

Learn more about Leap year