title: How to check if a number if divisible by two different values?
body: <p>I've only just started college, and one of the first things we're learning is Java. I'm currently learning about if statements. For one of my homework assignments, I need to write a program that asks for the user to input a year. Then, the program needs to determine whether that year is a leap year or not.</p>
  
  <p>The question states that if the year is divisible by 4, it is a leap year. Also, if the year is divisible by 100, it should also be divisible by 400 in order to be a leap year.</p>
  
  <p>This is what I've written so far:</p>
  
  <pre><code>        System.out.print("Type a year: ");
          int year = Integer.parseInt(reader.nextLine());
  
          if (year % 4 == 0 || year % 100 == 0 &amp;&amp; year % 400 == 0) {
              System.out.print("The year is a leap year.");
          } else {
              System.out.print("The year is not a leap year.");
          }
  </code></pre>
  
  <p>I'm expecting the program to check if the year is divisible by 4, or if the year is divisible by both 100 and 400.</p>
  
  <p>Right now, when I enter the year 1800, the output says the year is a leap year, but I'm expecting it to say it is not a leap year. I suspect this is because the if statement is true when one of the conditions is true, which is the case because 1800 is divisible by 4. However, I can't seem to find out the right way to do it. Help would be much appreciated.</p>