因此,如果这看起来像是在要求您做作业,我深表歉意……我保证不是,我只是需要一些帮助,因为我以前从未使用过多维数组。我会问一个朋友或我的老师......但它是一个在线课程,因此得到回应......需要更长的时间然后从这里等待一个。到目前为止......我是唯一参加这门课程的人,所以朋友们对这些东西一无所知等等等等。所以......好吧,这个程序正在制作中......但我只是担心到目前为止,关于第一步,在他们的名字旁边列出每个学生和他们的 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("");
}
}