import java.util.*;
import java.io.*;
public class GradeBook
{
public static void main(String[] args)
{
System.out.println("Starting program\n\n");
String[] STUDENT_NAMES = new String[] {"Adams", "Baker", "Campbell", "Dewey", "East"};
int[][] STUDENT_GRADES = new int[5][3];
loadGradeArray(STUDENT_GRADES);
for (int i = 0; i < STUDENT_NAMES.length; i++)
{
System.out.printf("%-10s %5d %8d \n", STUDENT_NAMES[i], STUDENT_GRADES[i][0], STUDENT_GRADES[i][1]);
}
getStudentAverage(STUDENT_GRADES, STUDENT_NAMES);
} //end main
public static void getStudentAverage(int[][] grade, String[] name)
{
Scanner in = new Scanner(System.in);
double sum = 0;
double average = 0;
for(int row = 0; row<grade.length; row++)
{
for(int col = 0; col<grade[row].length; col++)
{
sum = sum + grade[row][col];
}
average = sum/2;
sum = 0;
System.out.println("The average of Student " + (row+1) + Arrays.toString(name) + " is: " + average);
}
}
public static void loadGradeArray(int[][] STUDENT_GRADES)
{
for(int row = 0; row<STUDENT_GRADES.length; row++)
{
for(int col = 0; col<STUDENT_GRADES[row].length; col++)
{
STUDENT_GRADES[0][0] = 75;
STUDENT_GRADES[0][1] = 75;
STUDENT_GRADES[1][0] = 100;
STUDENT_GRADES[1][1] = 75;
STUDENT_GRADES[2][0] = 84;
STUDENT_GRADES[2][1] = 75;
STUDENT_GRADES[3][0] = 80;
STUDENT_GRADES[3][1] = 75;
STUDENT_GRADES[4][0] = 50;
STUDENT_GRADES[4][1] = 75;
}
}
}
} //end class
Assignment for class has me creating a grade book for students using String[] to store first names, and int[5][3] to store two exam grades per student. Final product should give user the option the option of printing the class average for a test, or a students class grade
I am having trouble with the getStudentAverage method. I am confused on how to include the corresponding students name in the print statement. I want it to output something like this:
The average of Adam is: 75.0
The average of Baker is: 87.5
The average of Campbell is: 79.5
The average of Dewey is: 77.5
The average of East is: 62.5
Thanks in advance.