title: Initialize right variable for while loop
body: <p>I wrote a program to count the number of integers that are positive, negative or zero until you enter q to stop the program. I was asking if this is the correct way to set up the while loop if you are using the character "q" to terminate the program?</p>
  
  <pre><code>int number = 0;
      int count = 0;
      int total = 0;
      int positive = 0;
      int negative = 0;
      int zero = 0;
      boolean validInput = true;
  
  
  while(validInput == true){
      System.out.printf("Number (q to quit): ");
      if(input.hasNextInt()){
          number = input.nextInt();
          count++;
          total += number;
      }
      else if (number &gt; 0){
          positive++;
      }
      else if (number &lt; 0){
          negative++;
      }
      else if (number == 0){
          zero++;
      }
      if (validInput == false) {
          input.next();
      }
  </code></pre>