witchway915

Untitled

Sep 5th, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. CS 209 – Assignment #5
  2. Chapter 3: Introduction to classes, objects, methods, and strings - Read and study pp. 71-101
  3. Do the Chapter 3 Self-Review exercises (not for submission)
  4. 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
  5.  
  6. (20) 3.11 Modify class GradeBook (Fig. 3.10) as follows:
  7. a) Include a second String instance variable that represents the name of the course’s instructor.
  8. b) Provide a set method to change the instructor’s name and a get method to retrieve it.
  9. c) Modify the constructor to specify two parameters—one for the course name and one for the instructor’s name.
  10. 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.
  11. Use your modified class in a test application that demonstrates the class’s new capabilities.
  12.  
  13.  
  14.  
  15.  
  16. (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.
  17.  
  18.  
  19.  
  20.  
  21. (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