1. Member
Join Date
Jun 2011
Posts
12
Rep Power
0

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];
int[][] grades = new int[8][2];
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];
// tmpInt = grades[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;
System.out.print(grades[i][t] + " ");
}
int avgGrade = double / intSum;
System.out.println( "%5s %s \n" ",grades[i);
}
// }

}
}

2. 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

3. Member
Join Date
Jun 2011
Posts
12
Rep Power
0
thanks how di find it

4. 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.

5. 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

6. Member
Join Date
Jun 2011
Posts
12
Rep Power
0
sorr jos i cant find it

7. Originally Posted by belfast09
sorr jos i cant find it
Reread my previous reply; alternatively you can get to the blogs page by pressing 'Blogs' near the top of this page.

kind regards,

Jos

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•