# parallel arrays

• 06-13-2011, 10:54 AM
belfast09
parallel arrays
could somebody please tell me where im going wrong with my code to put grades beside student name i really need some help many thanks ive stuff commented out

code

public class arrays {

public static void main(String[] args) {
String[] students = new String [8];
String tmpStr;
int tmpInt;

students[0] = "Smith";
students[1] = "Jones";
students[2] = "Thompson";
students[3] = "Paul";
students[4] = "Jodan";
students[5] = "Cole";
students[6] = "Dunn";
students[7] = "Nolan";

// Arrays.sort(students);
// for(int t=0, t<students.length,-1 t++)
// for(int i=0, i<students.length,-1 i++)
// if(students[i].compareTo(students+1)>0){
// tmpStr = students[i];
// students[i] = students[i+1];
// students [i+1] = tmpStr;
// }
//
//// print students
int t;
int i;
for(i=0, i< students.length, i++){
System.out.printf(%s - 15s %s* students[i]);
int intSum = 0;
}
int avgGrade = double / intSum;
}
// }

}
}
• 06-13-2011, 10:59 AM
JosAH
Read my blog on this forum about sorting parallel arrays (using a Heapsort implementation). b.t.w. trying to sort parallel arrays is bad design from the old Fortran world ...

kind regards,

Jos
• 06-13-2011, 11:05 AM
belfast09
thanks how di find it
• 06-13-2011, 11:10 AM
kjkrum
As Jos says, parallel arrays is bad design. You really should create a Student class that contains names and grades, and create just one array of Students.
• 06-13-2011, 11:13 AM
JosAH
Quote:

Originally Posted by belfast09
thanks how di find it

In the right corner, just above my reply you see a link 'Blog entries 3'; click on the number ...

kind regards,

Jos
• 06-13-2011, 11:30 AM
belfast09
sorr jos i cant find it
• 06-13-2011, 11:48 AM
JosAH
Quote:

Originally Posted by belfast09
sorr jos i cant find it