• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why can student[x] be resolved?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:


(Marilyn added code tags)
[ March 06, 2004: Message edited by: Marilyn de Queiroz ]
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is helpful if you

1) Put your code in code tags when you post it

2) Point out which line is in question

for example:

student[x].getStudentNumber + // line 61
 
Aaron Parker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()); }}
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you don't have all your code posted (specifically the Student class), I will look into my crystal ball and predict that getStudentNumber has not been defined in the Student class or it is actually a method and you forgot the parenthesis :getStudentNumber()
 
Aaron Parker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Crud, sorry. Tried to add line numbers and it didn't work. Line 44 reads: student[x].getStudentNumber +
and line 61 reads: student[x].setGrade(y, tempGrade);
 
Aaron Parker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THANK YOU Mr. Morris! I would like to purchase one half dozen of your crystal balls! It was a method without ().
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic