How to make the java program not to accept any negative values
<p>I have made a program but I am having trouble with the <code>if/else</code> statement.</p>

<p>The program is not supposed to accept any negative values, but it does not step out of the loop when a negative value is entered. The code snippet is:</p>

<pre><code>try {
    System.out.println("Enter the number of numbers to add.");
    int n_nos1=Integer.parseInt(bx.readLine());
    double add=0,sub=0,pro=1,div=1;
    if(n_nos1!=0 &amp;&amp; n_nos1&gt;0)
    {
        System.out.println("Enter the number(s)");
        for(int i=1;i&lt;=n_nos1;i++)
        {
            double t=Double.parseDouble(bx.readLine());
            add+=t;
        }
    }
    else System.out.println("Either zero was entered or an invalid character was entered");
}
</code></pre>

<p>I have put the catch statement down. The trouble I am having here is that it still accepts the negative values.</p>