I have a 2D array called gradeTable. This array contains grades that fall into the categories of a, q, p, e, and f. I'm trying to create a method that takes in a new grade (i.e. a100, q90, e65) and adds that to the appropriate row. The grade is taken in as a string with the category following the numerical grade. I know I need to create a new array every time a new grade is added, but I'm not sure how to get each grade in it's appropriate spot. The method is a boolean and returns true if the grade is added and false if the category (the letter at the beginning of the string) isn't found. Any advice would be appreciated.
public boolean addGrade(String newGradeIn) {
char row = newGradeIn.charAt(0);
int grade = Integer.parseInt(newGradeIn.substring(1));
gradeTable[row] = Arrays.copyOf(gradeTable[row], gradeTable[row].length + 1);
}
That's all I have so far. I know it doesn't compile because I don't have a return statement.