Thursday, 10 September 2020

leap year or not(else-if)

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

Pattern 31 & 32