CS 102 LAB3 Basic Inheritance.


In this lab you will extend a class and use objects that inherit from other objects. You will implement a very simple employee payroll calculation system. There are two types of employees working for in the company that you are designing this program for. Some employees are payed a fixed salary while some are payed by the hour. The company works in a local with an old style progressive tax scheme. Taxes are determined based on bi-weekly gross pay and there is only one exemption available: Hourly workers are assumed to make less than salaried workers and so their first four hours of work are tax free;

The standard tax scale for taxable income is:
Bi-weekly taxable

BiWeekly Taxible Income of Tax Rate
more than 3500 20%
2001 to 3500
2000 or less

Wages mean something different for each type of employee. There is a single wage propery in the Employee class, however it means something different for each derived class.

For saleried employees the wage represents their yearly salary.
For hourly employees, the wage is their hourly wage.

As is common, you are not starting from scratch. The project has been designed for you (see the UML below) and you have the employee class half implemented for you.


The high level objectives of this lab are as follows:


Before you begin, look over your notes, look through chapter 13 of the book on inheritance, and ask about anything you don't understand.

Lab Tasks:

login to eagle.

Getting the files.

now copy the lab skeleton files to your directory:

cp ~jsantore/lab3Skeleton.zip .

unzip the skeleton files into your account.

unzip  lab3Skeleton.zip

Examining what you have:

move into the lab3 folder that was created when you unzipped the file.

cd lab3

Now look over the files, There is a pair of files containing the half finished Employee class. There is a header and cpp file. Compare the code to the UML diagram shown below. There aresome itemsshown on the UML that are not yet implemented. You will need to finish this class before you are done.

You will also find a file with a main function. This function will be used to test your implementation. After you have implemented all three classes, you need to do the fillowing things in the main function.

  • Create 2 Saleried Employees, one that has a yearly Salary of 35,000 and the other with a yearly salary of 78,435
  • Create 2 Hourly Employees, one that has an hourly pay of 10.00 and the other with an hourly rate of 23.42
  • Print paychecks for all four employess.
  • Beginning the project.

    Here is the UML for your project:

    Beginning your Coding:

    For best success, implement your project in the following order:

    Implement the rest of the Employee class in Employee.cpp. There are three member functions left to implement. getTaxRate must be implemented completely. The remaining two can be "stubbed out" (given minimal implementations)

    Implement the Salaried Employee class: create a header file and a cpp file and implement the SalariedEmployee in code. The member functions should be straightforward.

    Add the salaried employee to the make file and compile the program. Your instructor will go over minor make file modification in the recitation class.

    Implement the HourlyEmployee class: When implementing calculateGrossPay, query the user for the number of hours that this employee worked.

    Add this class to the make file.

    Modify the main function to create the objects listed in the summary section and print the appropriate paychecks. (you may need to call other functions between creating objects and printing paychecks of course)

    Write the readme.


    What to submit:

    You need to submit all your source code for this project, along with the makefile and a README.txt file
    The README.txt file should contain the following information.

    When you are ready to submit, zip up your lab3 directory

    zip -r Lab3Solution.zip lab3
    and submit it.

    Due Date:

    Due By Midnight Tuesday Oct 26th