Write a Java Program to find given number is Leap or Not using Nested if statement   
  
  
  
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%4==0&&Year%100!=0)||Year%400==0)
			{
			System.out.println("\n "+Year + " is Leap Year");
			}
			else
			{
			System.out.println("\n "+Year+" is a NOT Leap Year. ");
			}
	}
}
Output:
Enter Year:
2022
2022 is a NOT Leap Year.
 
     
No comments:
Post a Comment
If you have any doubts, please let me know