title: Calculate average of user input using for each
body: <p>Hi Im new to java and trying to do some exercises to familiarize myself with it. I am trying to calculate the sum and average of the user input numbers using a for each or enhanced for loop. What i have done is to store the numbers in an array. Can you please check if my code is correct. </p>
  
  <pre><code>Scanner scanner = new Scanner(System.in);
  
  double inputNum;
  double sum= 0;
  int counter;
  
  System.out.println("How many entries would you like input");
  int entry = scanner.nextInt();
  
  for (counter = 0; counter&lt; entry; counter++){
  
      double [] numbers = new double[entry]; 
      System.out.println("Please input number " + (counter +1));
      numbers[counter] = scanner.nextDouble();
  
      for (double x : numbers[counter]) {
          x += sum;
      }
  
      System.out.println("The total sum is: " + sum);
      double average = sum/entry;
      System.out.println("The total average is: " + average);
  }
  </code></pre>