我必须制作一个程序,收集作业总数,学生为每个作业标记。该程序返回每个学生的作业标记。这是我现在的输出窗口:
班上有多少学生? 2 用户输入= assignmentLimit
您指定了多少作业? 2 用户输入= studentLimit
Assigment 1 mark:
学生1:41 用户输入
学生2:52 用户输入
Assigment 2 marks:
学生1:74 用户输入
学生2:85 用户输入
学生1分
41.0
52.0
学生2分
74.0
85.0
但在学生1分部分下,我希望它显示41.0和74.0。对于学生2标记,我想显示52.0和85.0。我该怎么做?这是收集并显示标记的部分:
double[][] mark = new double[assignmentLimit][studentLimit];
for (index = 0; index < assignmentLimit; index++)
{
System.out.println("\nAssigment " + (index + 1) + " marks:");
for (int studentMark = 0; studentMark < studentLimit; studentMark++)
{
System.out.print("\nStudent " + (studentMark + 1) + ": ");
mark[index][studentMark] = Integer.parseInt(console.readLine());
} // end of for(int index = 0; index < ARRAY_LIMIT; index++)
}
for (index = 0; index < studentLimit; index++)
{
System.out.println("\nStudent " + (index + 1) + " marks");
for (int studentMark = 0; studentMark < assignmentLimit; studentMark++)
{
System.out.println("\t" + mark[index][studentMark]);
}
}
答案 0 :(得分:1)
试试这个:
double[][] mark = new double[assignmentLimit][studentLimit];
for (index = 0; index < assignmentLimit; index++)
{
System.out.println("\nAssigment " + (index + 1) + " marks:");
for (int studentMark = 0; studentMark < studentLimit; studentMark++)
{
System.out.print("\nStudent " + (studentMark + 1) + ": ");
mark[index][studentMark] = Integer.parseInt(console.readLine());
} // end of for(int index = 0; index < ARRAY_LIMIT; index++)
}
for (index = 0; index < studentLimit; index++)
{
System.out.println("\nStudent " + (index + 1) + " marks");
for (int studentMark = 0; studentMark < assignmentLimit; studentMark++)
{
System.out.println("\t" + mark[studentMark][index]); // mark[studentMark][index] but not mark[index][studentMark]
}
}