How to put a Scanner input into an array... for example a couple of numbers

WM. picture WM. · May 8, 2010 · Viewed 378.1k times · Source
Scanner scan = new Scanner(System.in);
double numbers = scan.nextDouble();
double[] avg =..????

Answer

npinti picture npinti · May 8, 2010

You could try something like this:

public static void main (String[] args)
{
    Scanner input = new Scanner(System.in);
    double[] numbers = new double[5];

    for (int i = 0; i < numbers.length; i++)
    {
        System.out.println("Please enter number");
        numbers[i] = input.nextDouble();
    }
}

It seems pretty basic stuff unless I am misunderstanding you