/*

This program first determines from its user the size n of a list that is to be extracted. 
The program then extracts n values from the standard input stream and uses them to set 
the values of the elements of array number[]. The program then determines and displays 
the average of the values in the array.

*/

import java.util.*;

public class ArrayFun {
   public static void main(String[] args) {
      // determine list size
      Scanner scan = new Scanner(System.in);
      System.out.print("Enter list size: ");
      int n = scan.nextInt();
      System.out.println();

      // create a list of proper size
      int[] number = new int[n];

      // assign input values to list
      for (int i = 0; i < number.length; ++i) {
          System.out.print("Number: ");
          number[i] = scan.nextInt();
      }
      System.out.println();

      // calculate average
      int sum = 0;
      for (int i = 0; i < number.length; ++i) {
          sum = sum + number[i];
      }
      double average = (double)sum / number.length;

      // display result
      System.out.println("The average is " + average);
   }
}
