/* BasicArray.java -- Basic array example program
   by Craig Persiko for CS 111A

   Inputs a series of numbers into an array, averages them,
   and outputs them.
*/

import java.util.Scanner;


class BasicArray
{
  public static void main(String[] args)
  {
    Scanner sc;
    sc = new Scanner(System.in);

    double[] inputNums;
    int size, i;
    double sum = 0;

    System.out.print("How many numbers do you want to enter? ");
    size = sc.nextInt();

    inputNums = new double[size];

    System.out.println("Please enter those numbers, hitting return after each one.");
    for (i=0; i < size; i++)
    {
      inputNums[i] = sc.nextDouble();
      sum += inputNums[i];
    }

    System.out.println("You entered:");
    for (i=0; i < size; i++)
      System.out.print(inputNums[i] + " ");

    System.out.println("\nThe average of those numbers is: " + (sum / size));

  }
}

/* Sample Output:

How many numbers do you want to enter? 5
Please enter those numbers, hitting return after each one.
10.5
75
0.7
15
7.7
You entered:
10.5 75.0 0.7 15.0 7.7
The average of those numbers is: 21.78

*/


syntax highlighted by Code2HTML, v. 0.9