title: Close list with variables with the fixed number -1
body: <p>I am very new to coding and Java. I have the following assignment: Write a program that reads a couple of positive numbers from the input and computes and prints the average, with 3 decimals precision. The input list closes with the number -1.</p>
  
  <p>So I have a working program, however I have no clue how to integrate the condition 'print the average with 3 decimals precision'. Do you have any idea how to fix this? Many thanks!</p>
  
  <p>See my code below:</p>
  
  <p>import java.util.Scanner;</p>
  
  <p>public class Parta {</p>
  
  <pre><code>public static void main(String[] args){
      Scanner numInput = new Scanner(System.in);
  
      double avg = 0.0;
      double count = 0.0;
      double sum = 0.0;
  
      System.out.println("Enter a series of numbers. Enter -1 to quit.");
  
      while (numInput.hasNextDouble())
      {
          double negNum = numInput.nextDouble();
          if (negNum == -1)
          {
              System.out.println("You entered " + count + " numbers averaging " + avg + ".");
              break;
          }
          else
          {
              sum += negNum;
              count++;
              avg = sum/count;
          }
      }
  }
  </code></pre>
  
  <p>}</p>