Java Program using nested if condition…

This java code is to show you the use of nested if condition.
class NestedIf
{
      public static void main(String args [])
      {
                  int year;
                  year=Integer.parseInt(args [0]);
                 
                  if(year%100==0)
                  {
                              if(year%400==0)
                              {
                                          System.out.println(“Leap Year”);
                              }
                              else
                              {
                                          System.out.println(“Not leap year”);
                              }
                  }
                  else if(year%4==0)
                  {
                              System.out.println(“Leap Year”);      
                  }
                  else
                  {
                              System.out.println(“Not leap year”);
                  }
      }
}
Output:

D:java >java NestedIf 1700

Not leap year

Add Comment