Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CS 209 – Assignment #5
- Chapter 3: Introduction to classes, objects, methods, and strings - Read and study pp. 71-101
- Do the Chapter 3 Self-Review exercises (not for submission)
- Download the file assgn05.docx from the assignments folder – complete the problems, copy and paste your Java source code and sample output in the file, prefix your first initial and last name to the file name, e.g., fwilson_assgn05.docx, and upload your word processor solutions file by the due date. - Total points: 50
- (20) 3.11 Modify class GradeBook (Fig. 3.10) as follows:
- a) Include a second String instance variable that represents the name of the course’s instructor.
- b) Provide a set method to change the instructor’s name and a get method to retrieve it.
- c) Modify the constructor to specify two parameters—one for the course name and one for the instructor’s name.
- d) 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.
- Use your modified class in a test application that demonstrates the class’s new capabilities.
- (10) 3.12 Modify class Account (Fig. 3.13) to provide a method debit that withdraws money from an Account. Ensure the debit amount does not exceed the Account’s balance. If it does, leave the balance unchanged and the method should print a message indicating "Debit amount exceeded account balance." Modify class AccountTest (Fig. 3.14) to test method debit.
- (20) 3.14 Create a class Employee that includes three pieces of information as instance variables - a first name (type String), a last name (type String) and a monthly salary (double). Your class should have a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, set it to 0.0. Write a test application named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.
Advertisement
Add Comment
Please, Sign In to add comment