Let’s see a program to check given year is a leap year or not in java
package programnew; import java.util.Scanner; public class LeapYear { public static void main(String[] args) { System.out.println("Enter a year"); Scanner in = new Scanner(System.in); int n = in.nextInt(); if (n % 4 == 0) { System.out.println("Given year is a leap year"); } else { System.out.println("Given year is not a leap year"); } } }
Output is :-
Enter a year
2003
Given year is not a leap year