The program below is the answer to Deitel’s Java How to Program (9th Edition) Chapter 3 Exercise 3.11.

Question: Modify class GradeBook (Fig. 3.10) as follows:

  1. Include a String instance variable that represents the name of the course’s instructor.
  2. Provide a set method to change the instructor’s name and a get method to retrieve it.
  3. Modify the constructor to specify two parameters — one for the course name and one for the instructor’s name.
  4. Modify method displayMessage to output the welcome message and course name, followed by “This course is presented by: ” and the instructor’s name.

Use your modified class in a test application that demonstrates the class’s new capabilities.

To run the application save both files with the same name as the class (because it is a public class) and with the .java file extension (in this case Ex03_11.java and Ex03_11_Test.java). Then compile both classes  and run Ex03_11_Test. Ex03_11 will not run because it does not have a main method.

To compile both classes at the same time using the command prompt, use the command

javac Ex03_11.java Ex03_11_Test.java

To run Ex03_11_Test, use the command

java Ex03_11_Test

Below is Class Ex03_11_Test.java to test class Ex03_11

Click here to see other answers to Java How to Program.

1 Comment

  1. I just couldn't leave your website without telling you that I truly enjoyed the top quality info you present to your visitors. I will be back again frequently to check up on new posts.

Write A Comment