-2

ですから、宿題をするように頼んでいるように思われる場合は、お詫び申し上げます...そうではないことを約束します。これまで多次元配列を使用したことがないため、助けが必要です。友達や先生に聞いてみますが、オンラインのコースなので、こちらからの返信を待つよりも時間がかかります。そして今のところ... このコースを受講しているのは私だけなので、友達はこのことについて何も知りません.これまでのステップ 1 については、各生徒と 4 つのマークを名前の横にリストしています。

元。

John Smith 67 87 56 97

Jane Doe 87 56 76 92

などなど

それが目標です。シンプルに……と思った。以下は私の変数の一部です...

public class StudentGradesView extends FrameView {

    int [][] aryStudent = new int [15][4]; //This is for the 15 students that can be inputted and 4 marks each.
    int numOfStudents = 0; //number of students start of at zero until inputted...
    int marks = 0; // not in use at this given moment

public StudentGradesView(SingleFrameApplication app) {

//unimportant....

}

 private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          

        numOfStudents ++;
        String currentList = studentListField.getText();

        //This picks up the four different marks from four different Fields...

        aryStudent[numOfStudents][0] = Integer.parseInt(test1Field.getText());
        aryStudent[numOfStudents][1] = Integer.parseInt(test2Field.getText());
        aryStudent[numOfStudents][2] = Integer.parseInt(test3Field.getText());
        aryStudent[numOfStudents][3] = Integer.parseInt(test4Field.getText());

        //now the problem is when I press the add button which adds student names and mark) it only inputs 
        //the name and the last mark inputted in the test4field. What am I missing that loops all the grades from test1Field - test4Field?

    for (int x=0; x < numOfStudents ; x++) {
        for (int y=0; y < 4; y++) {

        studentListField.setText("" + firstNameField.getText() + " " + lastNameField.getText() + " " + aryStudent[numOfStudents][y] + "\n" + currentList);

        }
        System.out.println("");
    } 
}                  
4

2 に答える 2