Java – how to put scanner input into an array… For example, several numbers
•
Java
Scanner scan = new Scanner(system.in);
Scanner scan = new Scanner(system.in); double numbers = scan.nextDouble(); double[] avg =..????
Solution
You can 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();
}
}
This seems to be a very basic thing unless I misunderstand you
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
