Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 2: Another Employee Type The files Firm.java, Staff.java, StaffMember.java, Volunteer.java, Employee.java, Executive.java, and Hourly.java are from Listings 9.1 9.7 in the text. The program

Lab 2: Another Employee Type

The files Firm.java, Staff.java, StaffMember.java, Volunteer.java, Employee.java, Executive.java, and Hourly.java are from Listings 9.1 9.7 in the text. The program illustrates inheritance and polymorphism. In this exercise you will add two more employee type to the class hierarchy (see Figure 9.1 in the text). One of the new employee types will be an intern, but earns a commission on sales. Hence the class, which we'll name CommissionIntern, will be derived from the Volunteer class. The second employee type will also be an intern but is not paid.

--Write a class named Commission with the following features:

It extends the Volunteer class.

It has one instance variable (in addition to those inherited - commission rate for the employee (the commission rate will be type double and will represent the percent (in decimal form) commission the employee earns on sales (so .2 would mean the employee earns 20% commission on sales)).

The constructor takes 4 parameters: the first 3 are the same as for Volunteer (name, address, phone number) and the 4th is the commission rate for the employee. The constructor should call the constructor of the parent class with the first 3 parameters then use the 4th to set the commission rate.

One additional method is needed: public void addSales (double totalSales) that adds the parameter to the instance variable representing total sales.

The pay method must call the pay method of the parent class to compute the pay from commission on sales. (See the pay method in the Executive class.) The total sales should be set back to 0.

The toString method needs to call the toString method of the parent class then add the total sales to that.

--Write a second class named FreeIntern using the same ideas as above, but be sure that it fits the scenario.

To test your classes, update Staff.java as follows:

Increase the size of the array to 10.

Add two interns to the staffListmake up your own names, addresses, and phone numbers. Have one of the employees earn a 10% commission and the other one earn a15% commission.

For the first additional employee you added, put the total sales $150; for the second, put the sales at $95.

Add two non-paid interns to the staffList

Be sure that you test your program, and that you have adequate output that shows that your code is working.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

What is an unbounded solution?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago