title: java program that finds average with average method
body: <p>I have a program that will average your numbers from the command line. Everything is in the main method. 
  1. The program should run allowing you to enter one number at a time and when you press enter it asks you for another number or offers the ability to press Q to get your average. 
  2. The program has a limit set to 20 numbers added. When you hit 21 the program notifies you that you added to many numbers and shuts down.
  3. If you enter multiple numbers on the same line and press enter, for every number you enter it System.out.println a message once for every number instead of just once. </p>
  
  <p>I would like to understand how to change the program to do these things. </p>
  
  <ol>
  <li>How to get the System.out.println to only appear one time per entry.</li>
  <li>How to get the program to output the average of 20 before it ends when someone enters 21</li>
  <li><p>how do i change it to create a method for averaging outside of main then call on the averaging method inside the main.</p>
  
  <pre><code>import java.util.Scanner;
  
  class programTwo {
  
  public static void main (String[] args) {
      Scanner scan = new Scanner(System.in);
      double sum = 0;
      int count = 0;
      System.out.println ("Enter your numbers to be averaged:");
      String inputs = scan.nextLine();
  
      while (!inputs.contains("q")) {
          Scanner scan2 = new Scanner(inputs); // create a new scanner out of our single line of input
  
          while(scan2.hasNextDouble()) {
              sum += scan2.nextDouble();
              count += 1;
              System.out.println("Please enter another number or press Q for your average");
          } 
  
          if(count == 21)
          {
              System.out.println("You entered too many numbers! Fail.");
              return;
          }
          inputs = scan.nextLine();
      }
      System.out.println("Your average is: " + (sum/count));
  }
  </code></pre></li>
  </ol>