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("Enter Year: "); int year = s.nextInt(); if ( year % 4 == 0) { if (year%100 == 0) { if(year%400 == 0) { System.out.println("\n"+year+" is a Leap Year. "); } else { System.out.println("\n"+year+" is a NOT Leap Year."); } } else { System.out.println("\n"+year+" is a Leap Year. "); } } else { System.out.println("\n"+year+" is a NOT Leap Year. "); } } }
Output:
Enter Year:
2010
2010 is a NOT Leap Year.
Bhut shi
ReplyDelete