title: Java Code for calculating Leap Year
body: <p>I am following "The Art and Science of Java" book and it shows how to calculate a leap year.
  The book uses ACM Java Task Force's library.</p>
  
  <p>Here is the code the books uses:</p>
  
  <pre><code>import acm.program.*;
  
  public class LeapYear extends ConsoleProgram {
      public void run()
      {
  
          println("This program calculates leap year.");
          int year = readInt("Enter the year: ");     
  
          boolean isLeapYear = ((year % 4 == 0) &amp;&amp; (year % 100 != 0) || (year % 400 == 0));
  
          if (isLeapYear)
          {
              println(year + " is a leap year.");
          } else
              println(year + " is not a leap year.");
      }
  
  }
  </code></pre>
  
  <p>Now, this is how I calculated the leap year. </p>
  
  <pre><code>import acm.program.*;
  
  public class LeapYear extends ConsoleProgram {
      public void run()
      {
  
          println("This program calculates leap year.");
          int year = readInt("Enter the year: ");
  
          if ((year % 4 == 0) &amp;&amp; year % 100 != 0)
          {
              println(year + " is a leap year.");
          }
          else if ((year % 4 == 0) &amp;&amp; (year % 100 == 0) &amp;&amp; (year % 400 == 0))
          {
              println(year + " is a leap year.");
          }
          else
          {
              println(year + " is not a leap year.");
          }
      }
  }
  </code></pre>
  
  <p>Is there anything wrong with my code or should i use the one provided by the book ?</p>
  
  <p>EDIT :: Both of the above code works fine, What i want to ask is which code is the best way to calculate the leap year. </p>