Thursday 10 September 2020

leap year or not(using method)

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:

No comments:

Post a Comment

If you have any doubts, please let me know

Pattern 31 & 32