What is the correct code to do this:
a new method called calculatePercentage with parameters int exam[][] int percentages[] and returntype void?
The method has to calculate all the percentages which have been stocked in int exam[][]. The objects stored in this exam[][] are results on /20. The percentages have to be on /100.
Thank you very much because I have no idea that works.
How the data in exam[][] is inserted
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++;
}
}
The new method I wrote:
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[]
}
}
The double array exam has 3 rows and 5 colums.
Start from something like this: