执行此操作的正确代码是什么:
一个名为calculatePercentage
的新方法,参数为int exam[][] int percentages[]
,返回类型为void
?
该方法必须计算int exam[][]
中存储的所有百分比。存储在此exam[][]
中的对象是/ 20的结果。百分比必须为/ 100。
非常感谢你,因为我不知道它有效。
如何插入考试[] []中的数据
private void insertExamResults(int array[][])
{
int[] exam = new int[3];
for (int teller = 0; teller < 3; teller++)
{
int i = 0;
exam[i] = Integer.parseInt(JOptionPane.showInputDialog("Exams of student " + teller + " (max = 5)"));
i++;
}
}
我写的新方法:
public void calculatePercentage(int exam[][], int percentages[])
{
for (int i = 0; i < 3; i++)
for (int j = 0; j < 5; j++)
{
//code for the sum of all elements on row
//stock this new value in a new array percentages[]
}
}
双阵列考试有3行5列。
答案 0 :(得分:0)
从这样的事情开始:
for (int i=0; i < 8; i++)
for (int j=0; j < 8; j++)
board[i][j] = i+j;