... student < grades.length; student++) { 137           System.out.printf("Student %2d", student + 1);
138
139           for (int test : grades[student]) // output student's grades
140              System.out.printf("%8d", test);
141           }
142
143           // call method getAverage to calculate student's average grade;
144           // pass row of grades as the argument to getAverage
145           double average = getAverage(grades[student]);
146           System.out.printf("%9.2f%n", average);
147        }
148     }
149  } 

Fig. 7.17 GradeBookTest creates GradeBook object using a two-dimensional array of grades, then invokes method processGrades to analyze them.


 1   // Fig. 7.17: GradeBookTest.java
 2   // GradeBookTest creates GradeBook object using a two-dimensional array
 3   // of grades, then invokes method processGrades to analyze them.

Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.