• May 16th, 2011, 09:51 PM
Melawe
Hello everyone! :)

Got an assignment I got to do and i'm completely befuddled. All I got to do is: "Create a program that uses a multidimensional array to store student grades. The first dimension should be a number for each student's grades, and the second dimension should be for each student's grades. Display the average of all the grades earned by each student and an overall average for every student."

I have no clue how that should be done; all I got atm is student grades.

Code Java:

```class Hr9StudentGrader { public static void main(String []args){ int twodim [][] = new int[6][6]; twodim[0][0] = 30; twodim[0][1] = 26; twodim[0][2] = 88; twodim[0][3] = 96; twodim[0][4] = 72; twodim[0][5] = 81; twodim[1][0] = 48; twodim[1][1] = 36; twodim[1][2] = 95; twodim[1][3] = 63; twodim[1][4] = 100; twodim[1][5] = 54; twodim[2][0] = 68; twodim[2][1] = 49; twodim[2][2] = 36; twodim[2][3] = 65; twodim[2][4] = 65; twodim[2][5] = 32; twodim[3][0] = 46; twodim[3][1] = 56; twodim[3][2] = 65; twodim[3][3] = 65; twodim[3][4] = 46; twodim[3][5] = 95; twodim[4][0] = 66; twodim[4][1] = 46; twodim[4][2] = 84; twodim[4][3] = 98; twodim[4][4] = 46; twodim[4][5] = 35; twodim[5][0] = 78; twodim[5][1] = 69; twodim[5][2] = 98; twodim[5][3] = 98; twodim[5][4] = 82; twodim[5][5] = 64;   } }```
• May 16th, 2011, 10:04 PM
vanDarg
I'm sure you know how to calculate average: average = total of scores / number of scores

Loop through each student, keeping track of the total scores. After you iterate through one student, perform the average calculation by dividing that particular student's score by the total number of scores (which will be 6).

To calculate the total average.
You can just add up each individual student's average and then divide by the number of students.
• May 18th, 2011, 01:08 AM
Melawe
Thanks for putting it that way! :D

Code java:

```class Hr9StudentGrader { public static void main(String []args){ int twodim [][] = new int[6][6];   twodim[0][0] = 30; twodim[0][1] = 26; twodim[0][2] = 88; twodim[0][3] = 96; twodim[0][4] = 72; twodim[0][5] = 81;   twodim[1][0] = 48; twodim[1][1] = 36; twodim[1][2] = 95; twodim[1][3] = 63; twodim[1][4] = 100; twodim[1][5] = 54;   twodim[2][0] = 68; twodim[2][1] = 49; twodim[2][2] = 36; twodim[2][3] = 65; twodim[2][4] = 65; twodim[2][5] = 32;   twodim[3][0] = 46; twodim[3][1] = 56; twodim[3][2] = 65; twodim[3][3] = 65; twodim[3][4] = 46; twodim[3][5] = 95;   twodim[4][0] = 66; twodim[4][1] = 46; twodim[4][2] = 84; twodim[4][3] = 98; twodim[4][4] = 46; twodim[4][5] = 35;   twodim[5][0] = 78; twodim[5][1] = 69; twodim[5][2] = 98; twodim[5][3] = 98; twodim[5][4] = 82; twodim[5][5] = 64;   int SIX = 6; int issac = 0; int dawiet = 0; int alem = 0; int ghebremariam = 0; int daniel = 0; int minus = 0;   for(int index = 0; index < 6; index++){ issac = issac + twodim[0][index]; } issac = issac / SIX; System.out.println("The average grade mark of Issac is: " + issac);   for(int index = 0; index < 6; index++){ dawiet = dawiet + twodim[1][index]; } dawiet = dawiet / SIX; System.out.println("The average grade mark of dawiet is: " + dawiet);   for(int index = 0; index < 6; index++){ alem = alem + twodim[2][index]; } alem = alem / SIX; System.out.println("The average grade mark of alem is: " + alem);   for(int index = 0; index < 6; index++){ ghebremariam = ghebremariam + twodim[3][index]; } ghebremariam = ghebremariam / SIX; System.out.println("The average grade mark of ghebremariam is: " + ghebremariam);   for(int index = 0; index < 6; index++){ daniel = daniel + twodim[4][index]; } daniel = daniel / SIX; System.out.println("The average grade mark of daniel is: " + daniel);   for(int index = 0; index < 6; index++){ minus = minus + twodim[5][index]; } minus = minus / SIX; System.out.println("The average grade mark of minus is: " + minus); } }```
Output:
run:
The average grade mark of Issac is: 65
The average grade mark of dawiet is: 66
The average grade mark of alem is: 52
The average grade mark of ghebremariam is: 62
The average grade mark of daniel is: 62
The average grade mark of minus is: 81
BUILD SUCCESSFUL (total time: 4 seconds)