title: How do I update the integer while the loop is running?
body: <p>When we enter 0 in the program it is supposed to stop running the loop and print the average of the numbers. When I run the program and initially enter 0, the program exits. If I enter in an integer that is not zero first, and then enter 0, the program keeps running and I can't quit.I figure that the integer value needs to update when the user enters a new value for the program to quit, and the sum to be correct.</p>
  
  <p>How do I update the integer value while the loop is running? I should change or add something in the loop I'm guessing.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Exercise05_01 {
  
      public static void main(String[] args){
  
          float negCount = 0;
  
          float sum = 0;
  
          float posCount = 0;
  
          Scanner input = new Scanner(System.in);
  
          System.out.println("Enter a positive or negative integer. Entering 0 ends program");
  
          int integer = input.nextInt();
  
          while (integer != 0) {
              if (integer &gt; 0) {
                  posCount = +1;
                  sum = +integer;
              }
              if (integer &lt; 0) {
                  negCount = +1;
                  sum = +integer;
              }
  
              float count = negCount + posCount;
  
              if (integer == 0) {
                  System.out.println("The answer");
              }
          }
      }
  }
  </code></pre>