Write a Java Program to find given number is Leap or Not using method
import java.util.Scanner; public class Leap { void leapYearOrNot() { Scanner s = new Scanner(System.in); System.out.println("Enter Year: "); int Year = s.nextInt(); if((Year%4==0 && Year%100!=0)||Year%400==0) { System.out.println(Year + " is Leap Year"); } else { System.out.println("It is Not a Leap Year"); } } public static void main(String[] args) { Leap obj = new Leap(); obj.leapYearOrNot(); } }
Output:
Enter Year:
2010
2010 is a NOT Leap Year.