有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java数组和循环结构

static Scanner scan = new Scanner(System.in);
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
    System.out.println("Enter number of arrays: ");
    int noOfArrays = scan.nextInt();
    String students[] = new String[noOfArrays];

    System.out.println("----------------------");
    while (true){
    System.out.println("Enter Student names and scores:");

    for (int idx = 0; idx < students.length; idx++){
    int scores[] = new int[noOfArrays];
        System.out.println("\t"+ (idx+1)+ ". ");
        String studName = sc.nextLine();
        students[idx] = studName;
        for (int indx = 0; indx < scores.length; indx++){
            System.out.println("\t Score: ");
            int score = sc.nextInt();
            scores[indx] = score;            
        }            
        }
    }

}

我需要这个输出,有人能帮我吗

Enter number of arrays: 3
"----------------------
Enter Student names and scores:
    1. Name
    Score: 81
    2. Name2
    Score: 82
    3. Name3
    Score: 83

共 (0) 个答案