Build a complete grade tracker that stores grades for students, each with exam scores. Use a D array where each row represents a student and each column represents an exam.
Your program should:
Print each student's scores on one line
Print each student's average
Print the class average across all students
Print the highest individual score in the entire class
Here is a starting structure:
import java.util.Arrays;
int[][] grades = {
{88, 76, 92},
{95, 89, 84},
{70, 65, 78},
{100, 97, 93},
{82, 88, 75}
};
double classTotal = 0;
int classMax = grades[0][0];
for (int i = 0; i < grades.length; i++) {
int studentSum = 0;
for (int j = 0; j < grades[i].length; j++) {
studentSum += grades[i][j];
if (grades[i][j] > classMax) {
classMax = grades[i][j];
}
}
double studentAvg = (double) studentSum / grades[i].length;
classTotal += studentSum;
System.out.println("Student " + (i + 1)
+ ": " + Arrays.toString(grades[i])
+ " | Avg: " + studentAvg);
}
int totalScores = grades.length * grades[0].length;
double classAvg = classTotal / totalScores;
System.out.println("Class average: " + classAvg);
System.out.println("Highest score: " + classMax);
This project combines D arrays, nested loops, accumulator patterns, and the Arrays utility class. Try modifying it to also find which student has the highest average.