title: Count Even and Odd Numbers User has Inputted - java
body: <p>Hi this is what a question on a course I am doing wants...</p>
  
  <ol>
  <li>The program prints "Type numbers” until the user types the number
  -1. When the user types the number -1, the program prints "Thank you and see you later!" and ends</li>
  <li>the program should print the sum of the numbers entered by the user
  (without the number -1).</li>
  <li>the program should print how many numbers the user typed (without
  the number -1).</li>
  <li><p>the program should print the average of the numbers the user typed
  (without the number -1).</p>
  
  <p><strong>5. the program should print the number of even and odd numbers that the
  user typed (without the number -1).</strong></p></li>
  </ol>
  
  <p>I have completed 1-4 but am completely stuck on 5. I did make a start on trying to work it out including putting a for loop inside my while loop but apart from the fact it didnt work it looked well out of place so i removed it. Anyway here is what i have done so far which as I say all works in its own magical way.</p>
  
  <p>And so if anyone can <strong>help me with question 5</strong> that would be great. ps.I'm sure what i've done so far could have been written better but don't focus on that for now cos for me and where i am with Java this is nothing short of a miracle.x </p>
  
  <pre><code>import java.util.Scanner;
  
  public class LoopsEndingRemembering { 
  
      public static void main(String[] args) {
          Scanner reader = new Scanner(System.in);
          int sum = 1;  // to counteract the -1 from the user
          int total = 0;
          double avg;
          //int even = 0;
          //int odd = 0;
  
          System.out.println("Type numbers:");
  
          while (true) {
              int numbers = Integer.parseInt(reader.nextLine());
  
              sum += numbers;
              total++;
              avg = ((double) sum) / (total - 1);
  
              if (numbers == -1) {
  
                  System.out.println("Thank you and see you later!");
                  System.out.println("The sum is " + sum);
                  System.out.println("How many numbers: " + (total - 1));
                  System.out.println("Average: " + avg);
                  //System.out.println("Even numbers: " + even);
                  //System.out.println("Odd numbers: " + odd);
                  break; 
              }
          }
      }
  }
  </code></pre>