title: Using while loop in java
body: <p>I'm trying to read in and add up (only) positive integers until a negative integer is entered. The program is supposed to stop only when a negative integer is entered. The best I've been able to come up with is the code below but the problem is it doesn't stop even when a negative integer is read. PS: I'm still learning so please bear with me. I've tried adding <code>&amp;&amp; input2!&lt;0</code> to the while loop condition but it comes up as an error. Any suggestions as to how I can make it behave the way I want it to? Thanks.</p>
  
  <pre><code>public class Total{
      public static void main(String[] args){
  
              System.out.println("Enter an integer: ");
  
              Scanner entry = new Scanner(System.in);
              int input1 = entry.nextInt();
  
              System.out.println("Enter another integer: ");
              int input2 = entry.nextInt();
  
              int total = input1 + input2;
  
              while (input2 &gt; 0){            
                  System.out.println(total + "\nEnter another interger:  ");
                  total += entry.nextInt();
              }
      }
  }
  </code></pre>