How does one add code tags?
The compiler has no problem resolving student[x] in line 61, but can't figure it out in line 44? Why not?
I'm getting this compiler error:
src/java192/project3/GradePoint.java:44: cannot resolve symbol
symbol : variable getStudentNumber
location: class Student
student[1].getStudentNumber +
^
(carat under [ )
My code:
code:
--------------------------------------------------------------------------------
public class GradePoint { /** Description of the Field */ public static char validGrades[] = {'A', 'B', 'C', 'D', 'F'}; /** Description of the Field */ public static char tempGrade; private static Student[] student = new Student[2]; /** Description of the Field */ public static boolean found = false; /** * Description of the Method * *@exception Exception Description of the Exception */ public static void assignGrades() throws Exception { instantiateStudents(); getStudentData(); displayGrades(); } /** Description of the Method */ public static void instantiateStudents() { for (int x = 0; x < 2; ++x) { student[x] = new Student(); } } /** * Gets the studentData attribute of the GradePoint class * *@exception Exception Description of the Exception */ public static void getStudentData() throws Exception { for (int x = 0; x < 2; ++x) { for (int y = 0; y < 5; ++y) { System.out.print("Please enter Student #" + student[x].getStudentNumber +// line 44 "'s grade for class #" + (y + 1) + ": "); tempGrade = (char) System.in.read(); System.in.read(); System.in.read(); found = false; for (int z = 0; z < 5; ++z) {
String tempGradeString = Character.toString(tempGrade); String validGradesString = Character.toString(validGrades[z]); if (tempGradeString.equals(validGradesString)) { found = true; if (found == false) { System.out.println("Invalid entry--please reenter."); --y; } System.out.println(x); student[x].setGrade(y, tempGrade);//line 61 } } } } } /** Description of the Method */ public static void displayGrades() { student[0].toString(); System.out.println(student[0].toString()); student[1].toString(); System.out.println(student[1].toString()); }}