Method outputGrades

Method outputGrades (lines 132–156) uses nested for statements to output values of the array grades and each student’s semester average. The output (Fig. 7.19) shows the result, which resembles the tabular format of a professor’s physical grade book. Lines 138–139 print the column headings for each test. We use a counter-controlled for statement here so that we can identify each test with a number. Similarly, the for statement in lines 144–155 first outputs a row label using a counter variable to identify each student (line 146). Although array indices start at 0, lines 139 and 146 output test + 1 and student + 1, respectively, to produce test and student numbers starting at 1 (see the output in Fig. 7.19). The inner for ...

Get Java™ How To Program (Early Objects), Tenth 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.