new at java need some help

I have managed to get the program down from 10 errors to 4, and im stuck there. The error im getting is in the GradeBookTest.java file apparently:
"Cannot Find Symbol"



// fig 3.11 GradeBookTest.java
// Gradebook constructor used to specify the course name at the
// time each Gradebook object is created
public class GradeBookTest
{
//main method begins program execution
public static void main ( String [] args )
{
// create GradeBook Object
GradeBook gradeBook1 = new GradeBook(
courseName , instructorName );
GradeBook gradeBook2 = new GradeBook(
courseName , instructorName );

// display initial value of courseName for each Gradebook
System.out.printf ( "gradeBook1 course name is: %s
",
gradeBook1.getCourseName() );
System.out.printf ( "gradeBook2 course name is: %s
",
gradeBook2.getCourseName() );
} // end main
} // end class GradeBookTest
___________________________________________
THE SECOND FILE
// fig 3.10 GradeBook.java
// GradeBook class with a constructorto initialize the course Name
public class GradeBook
{
private String courseName; // course name for this GradeBook
private String instructorName; // instructor's name for this Gradebook

// constructor initializes courseName with String argument
public GradeBook ( String courseName, String instructorName)
{
setCourseName ( courseName) ;
setInstructorName ( instructorName );
} // end constructor

//method to set the course name
public void setCourseName ( String name )
{
courseName = name; // store the course name
} // end method setCourseName

// method to retrieve the course name
public String getCourseName ()
{
return courseName;
} // end method getCourseName

//method to set the instructor name
public void setInstructorName ( String name )
{
instructorName = name; // store the instructor name
} // end method setInstructorName

// method to retrieve the instructor name
public String getInstructorName ()
{
return instructorName;
} // end method getIntructorName

//display a welcome message to the GradeBook User
public void displayMessage ()
{
// this statement calls getCourseName to get the
// name of the course this GradeBook represents
System.out.printf ( "Welcome to the Grade Book for
%s!
",
getCourseName ());
} // end method displayMessage
}//end class GradeBook





Comments

  • Hey,
    What I see as a "Cannot Find Symbol" are courseName , instructorName in the gradeBook1 and gradeBook2 initialization statements,
    [code]// create GradeBook Object
    GradeBook gradeBook1 = new GradeBook(
    courseName , instructorName );
    GradeBook gradeBook2 = new GradeBook(
    courseName , instructorName );
    [/code] Those fields have not been defined and initialized in the GradeBookTest class. Solution depends on how the program is supposed to work. One solution is to define those variables before they are referenced and set their values before they are used. ie.
    [code] public static void main(String[] args) {
    String courseName, instructorName;
    // create GradeBook Object
    courseName = "Java Basics";
    instructorName = "Ben There";
    GradeBook gradeBook1 = new GradeBook(
    courseName, instructorName);
    courseName = "Java Advanced";
    instructorName = "Brave Heart";
    GradeBook gradeBook2 = new GradeBook(
    courseName, instructorName);
    // ...[/code]

    Regards, se52
  • I am new in development field and I want some help in initial stage because some problem arises for development. I started new project based on java it simple but I faced many problem. I am using netbeans IDE it is very simple but when I want to design gui then I can't create the gui.
    Can you help me for this in the project.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories