# arrays and multidimensional arrays

• 06-12-2011, 08:42 PM
belfast09
arrays and multidimensional arrays
I have set an array of 8 students and then 8 multidimensional arrays of 3 for their results i got their average but have to display which students has the minumum average score ive no problem displaying the minum average mark but cant link it to the student array to get the student name into the output with there mark here is my method i be very thankful of some help

public void Min()
{
int[] max = new int[8]; // allocates memory for 8 integers
max[0]= (marks[0][0] + marks[0][1] + marks[0][2])/3;
max[1]= (marks[1][0] + marks[1][1] + marks[1][2])/3;
max[2]= (marks[2][0] + marks[2][1] + marks[2][2])/3;
max[3]= (marks[3][0] + marks[3][1] + marks[3][2])/3;
max[4]= (marks[4][0] + marks[4][1] + marks[4][2])/3;
max[5]= (marks[5][0] + marks[5][1] + marks[5][2])/3;
max[6]= (marks[6][0] + marks[6][1] + marks[6][2])/3;
max[7]= (marks[7][0] + marks[7][1] + marks[7][2])/3;

Arrays.sort(max);
System.out.println("The minimum score is = " + max[0]);
• 06-12-2011, 09:34 PM
Norm
Can you explain what the code you posted is supposed to do?
How does the the printed message at the bottom relate to the code?

Do you see the repeating pattern in the code? 0 1 2 3 ... thru 7
When you see that you should think: loop
Your code should have a loop instead of the 8 statements you have.

Quote:

cant link it to the student array to get the student name
Are the arrays in parallel? The data for each student is at the same index in each array.
How do you get the index of the score that you are displaying? The code shows a constant index of 0 and not a variable.
• 06-12-2011, 09:52 PM
dlorde
Minimum average? what is that, and how is it calculated?
• 06-12-2011, 10:03 PM
belfast09
sorry mate no how do you loop this, im using the three marks and am using an array of all the student marks and using array.sort to get the lowest average when you talk about parallel index this is my mistake could you demonstrated sorry very new to java
• 06-12-2011, 10:10 PM
Norm