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

后端 未结 11 1701
青春惊慌失措
青春惊慌失措 2020-11-30 05:20
Scanner scan = new Scanner(System.in);
double numbers = scan.nextDouble();
double[] avg =..????
11条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 05:38

    This is a program to show how to give input from system and also calculate sum at each level and average.

    package NumericTest;
    
    import java.util.Scanner;
    
    public class SumAvg {
    
    
     public static void main(String[] args) {
    
     int i,n;
     System.out.println("Enter the number of inputs");
     Scanner sc = new Scanner(System.in);
     n=sc.nextInt();
     int a[] = new int [n];
    
        System.out.println("Enter the inputs");
       for(i=0;i

提交回复
热议问题