Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Okay, yeah you're right sorry I didn't realize that but anyway I still have my original problem, the value in the file is 0 now and it gives me the Error but if I set it to 2 it adds four and doesn't give me the error..</p> </blockquote> <p>This would suggest that your logic is wrong...</p> <p>Based on this code, lets do some desk checking...</p> <pre><code>if ( url &gt; 2) System.out.println ("Error"); if (url % 2 == 0) even = (Counter + 2); </code></pre> <p>Assuming <code>url == 4</code>...</p> <ul> <li><code>if (url &gt; 2)</code> = <code>if (4 &gt; 2)</code> = <code>true</code>, print <code>Error</code></li> <li><code>if (url % 2 == 0)</code> = <code>if (4 % 2 == 0)</code> = <code>true</code>, <code>even = Counter + 2</code></li> </ul> <p>Assuming <code>url == 2</code>...</p> <ul> <li><code>if (url &gt; 2)</code> = <code>if (2 &gt; 2)</code> = <code>false</code>, do nothing...</li> <li><code>if (url % 2 == 0)</code> = <code>if (2 % 2 == 0)</code> = <code>true</code>, <code>even = Counter + 2</code></li> </ul> <p>Assuming you want to print an error when the number is over <code>1</code> you should use <code>if (url &gt;= 2)</code> or <code>if (url &gt; 1)</code></p> <p>Assuming you don't want to continue calculating the result when you have an error, you should use an <code>if-else</code> statement, along the lines of...</p> <pre><code>if ( url &gt; 2) System.out.println ("Error"); else if (url % 2 == 0) { even = (Counter + 2); System.out.print(" " + even + " "); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload