Results 1 to 3 of 3
  1. #1
    awaken38 is offline Member
    Join Date
    Feb 2011
    Posts
    1
    Rep Power
    0

    Default GradeBook Class Modifications

    I am very new to programming in java and i am completely stuck on this problem i just dont see what i am doing wrong, if i could get some clarification that would be great.

    i need this program to display the courses name and instructors name when entered by the person using the program
    Java Code:
     public class GradeBook
    
    
      	private String courseName; 
    	private String instructorName ;
     
       // constructor initializes courseName with String supplied as argument
       public GradeBook( String name, String instructor )
       {
          courseName = name; // initializes courseName
    		instructorName = instructor;
       } // 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
    	
    	public void setInstructorName ( String instructor )
    	{
     		instructorName = instructor; // 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\n%s!\n", getCourseName());
    	} // end method displayMessage
    }//end class GradeBook
    Java Code:
    public class GradeBookTest
    {
    // main method begins program execution
    public static void main ( String args[] )
    {
    
    String courseName;
    String instructorName;
    
    Scanner input = new Scanner(System.in);
    
    		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\n",
    			gradeBook.getcourseName() );
    		System.out.printf ( "gradeBook2 course name is: %s\n",
    			gradeBook2.getcourseName() );
    	} // end main
    } // end class GradeBookTest

    Java Code:
    GradeBookTest.java:26: cannot find symbol
    symbol  : variable gradeBook
    location: class GradeBookTest
    			gradeBook.getcourseName() );
    			^
    GradeBookTest.java:28: cannot find symbol
    symbol  : method getcourseName()
    location: class GradeBook
    			gradeBook2.getcourseName() );
    			          ^
    2 errors
    Last edited by awaken38; 02-07-2011 at 09:49 PM.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    Java is case sensitive, getcourseName() is declared as having a capital C. Also, you forgot a 1 in gradeBook.getcourseName().

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    The first error is caused because you call
    Java Code:
    gradeBook.getCourseName()
    but you declare 2 gradebooks
    Java Code:
    gradeBook1 = new gradeBook(args);
    gradeBook2 = new gradeBook(args);

Similar Threads

  1. Replies: 5
    Last Post: 01-26-2011, 06:38 PM
  2. Replies: 8
    Last Post: 04-14-2010, 05:49 AM
  3. Replies: 7
    Last Post: 05-06-2009, 12:42 PM
  4. Replies: 8
    Last Post: 03-21-2009, 09:34 AM
  5. Replies: 0
    Last Post: 05-13-2008, 06:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •