title: Calling the function in setup in Processing
body: <pre class="lang-java prettyprint-override"><code>import javax.swing.JOptionPane;
  int year;
  boolean is_leap_year(int year)
  {
   if (((year % 4 == 0) &amp;&amp; (year % 100 != 0)) || (year % 400 == 0))
      return true;
   else
      return false;
  }
  
  void setup ()
  {
   String answer = JOptionPane.showInputDialog("Enter a year or a negative number to test");
   year = Integer.parseInt(answer);
  
   while (year &gt; 0) {
   boolean b = is_leap_year(year);
   if (b == true) {
   println( year + " is a leap year");
   }
   else{
   println( year + " is Not a leap year");
   answer = JOptionPane.showInputDialog("Enter a year or a negative number to test");
   year = Integer.parseInt(answer);
   }
  }
  }
  </code></pre>
  
  <p>I wrote the function is_leap_year to test if the input is a leap year or not. However, the program won't run on the basis of one error.</p>
  
  <blockquote>
    <p>(Line 3) "This method must return a result of type boolean."</p>
  </blockquote>
  
  <p>Haven't I already done that, because I put boolean as the function type in the header? I also put return true as the block of the if statement.</p>
  
  <p>Also, I'm not sure if the function can be called properly from setup. I feel as though I'm missing something.</p>
  
  <p>Any clarification would be appreciated.</p>
  
  <blockquote>
    <p>Edit: (Line 7 and 8) I completed it and added the else to return false.
    For some reason, Processing is crashing after printing "2000 is a leap year" in multiple lines when I input 2000. Is there an infinite loop going on? How do I fix it?</p>
  </blockquote>