Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Gradebook error?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Gradebook error?

    CIS 182 – Java Programming
    Assignment 04
    Each program must include the following as comments at the beginning of your classes.
    name
    student number
    assignment information
    program documentation
    Write (modify) the following 2 programs. When you have completed the programs, attach the Java source files ( GradeBook.java, GradeBookTest.java, Invoice.java, InvoiceTest.java ) in TalonNet to assignment A04.

    Program 1 - GradeBook class modifications

    Modify class GradeBook ( Fig 3.10 ) as follows: Here is a link to the source code for Figure 3-10 --> Figure_3.10 zip file
    Include a second String instance variable (field) that represents the name of the instructor for the course.
    Provide a set method to change the instructor's name and a get method to retrieve it.
    Modify the constructor to specify two parameters - one for the course name and one for the course instructor.
    Modify method displayMessage such that it first outputs the welcome message and course name, then outputs "This course is presented by: " followed by the instructor's name.
    Modify the GradeBookTest class to demonstrate the use of ALL the methods in the class.

    Program 2 - Invoice class

    Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables (fields) - a part number (type String), a part description (type String), a quantity of the item being purchased (type int), and a price for the item (type double).

    Your class should have a constructor that initializes the four instance variables. Provide set and a get methods for each instance variable. In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value.

    Write a test application named InvoiceTest to demonstrate the use of ALL the methods in the class.


    Instruction: Here is my code

    public

    class GradeBook
    {
    private String professorSurname;
    private String courseName;


    public GradeBook( String name )
    {
    courseName = name;
    professorSurname = surname;
    }

    public void setCourseName( String name )
    {
    courseName = name;
    }

    public void setProfessorSurname ( String surname )
    {
    professorSurname = surname;
    }

    public String getCourseName()
    {
    return courseName;
    }

    public String getProfessorSurname()
    {
    return professorSurname;
    }
    public void displayMessage()
    {
    System.out.printf( "Welcome to the grade book for\n%s!\n",
    getCourseName() );
    }

    }

    /************************************************** ************************
    * (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
    * Pearson Education, Inc. All Rights Reserved. *
    * *
    * DISCLAIMER: The authors and publisher of this book have used their *
    * best efforts in preparing the book. These efforts include the *
    * development, research, and testing of the theories and programs *
    * to determine their effectiveness. The authors and publisher make *
    * no warranty of any kind, expressed or implied, with regard to these *
    * programs or to the documentation contained in these books. The authors *
    * and publisher shall not be liable in any event for incidental or *
    * consequential damages in connection with, or arising out of, the *
    * furnishing, performance, or use of these programs. *
    ************************************************** ***********************/

    public

    class GradeBookTest
    {

    public static void main( String args[] )
    {

    GradeBook gradeBook1 = new GradeBook(
    "CS101 Introduction to Java Programming" );
    GradeBook gradeBook2 = new GradeBook(
    "CS102 Data Structures in Java" );


    System.out.printf( "gradeBook1 course name is: %s\n",
    gradeBook1.getCourseName() );
    System.out.printf( "gradeBook2 course name is: %s\n",
    gradeBook2.getCourseName() );
    System.out.printf("This gradeBook1 professor name is:y %s\n",
    gradeBook1.getProfessorSurname () );
    System.out.printf ("This gradeBook2 professor name is: %s\n",
    gradeBook2.getProfessorSurname () );

    }

    }

    Please help me: Thanks in advance


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Gradebook error?

    Please explain your problem. Do you have any specific questions?

    Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Gradebook error?

    why wont the code work?
    telling me professorSurname invalid

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Gradebook error?

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

    Please post the full text of the error messages. The messages give information that is needed to solve the problem.

  5. #5
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Gradebook error?

    GradeBook.java:12: cannot find symbol
    symbol : variable surname
    location: class GradeBook
    professorSurname = surname;
    ^
    1 error

    That's the error I get when I compile

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Gradebook error?

    cannot find symbol
    symbol : variable surname
    The compiler can not find a definition for the symbol: surname that is in scope where it is used.
    Where is it that variable defined?

Similar Threads

  1. java gradebook
    By gibson.nathan in forum Collections and Generics
    Replies: 1
    Last Post: December 24th, 2009, 09:23 PM