title: Java Program for Leap Years in a Range
body: <p>I cannot seem to figure out why it will not print more than one year in a range. I've got everything except that up and running so far.</p>
  <p>The starting year cannot be before 1752 and the ending year cannot be past 9999. I need the program to find all of the leap years in between the chosen starting year and the chosen ending year and then print all of those leap years off for the user.</p>
  <p>Everything seems to work fine until I added the <code>else if</code> at the end to print a message if there are no years in the given range. I would just remove it if I could but that message is a part of the requirements for my assignment.</p>
  <pre><code>import java.util.Scanner;
  class Final_Project_Mendenhall {
    public static void main(String[] args)
      {
          int startYear = 1752;
          int endYear = 9999;
          int i;
          int j = 0;
   
          Scanner in = new Scanner(System.in); //Scanner object to get user input for Start Year
          System.out.print(&quot;Enter the Start Year (Greater or equal to 1752):&quot;);
          startYear = in.nextInt(); //Get Start Year from user
              while (startYear &lt; 1752){
              System.out.println(&quot;Enter a valid start year (Greater or equal to 1752):&quot;);
              startYear = in.nextInt(); //Get valid Start Year from user
          } //End while
          
          System.out.print(&quot;Enter the End Year (Less than 9999):&quot;);
          endYear = in.nextInt(); //Get End Year from user
              while (endYear &gt; 9999){
              System.out.println(&quot;Enter a valid end year (Less than 9999):&quot;);
              endYear = in.nextInt(); //Get valid End Year from user
          } //End while
         
          System.out.println(&quot;Leap years:&quot;); //Print Leap Years
   
          for (i = startYear; i &lt;= endYear; i++){ //Loop through years between Start and End Years
            if ((0 == i % 4) &amp;&amp; (0 == i % 400)){ //Find and print Leap Years, if there are
              System.out.println(i);
              j++;
            }//End if
          //End for
           else if(j == 0){
              System.out.println(&quot;There are no leap years in that range&quot;);
          }//End if
        }
        }
      }
  </code></pre>