You are on page 1of 3

ShaheedZulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Total Marks: 04

Obtained Marks:

Object Oriented
Programming
Assignment # 03
Last date of Submission: 24 April 2019

Submitted To: Muhammad Usman


___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Student Name:
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Reg Number:
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Object Oriented BS(SE)-2 SZABIST-ISB


Programming
ShaheedZulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Instructions:Copied or shown assignments will be marked zero. Late submissions are not
entertained in any case.
Question
A company pays its employees weekly. The employees are of four types:
 Salaried employees are paid a fixed weekly salary regardless of the number of hours worked,
 hourly employees are paid by the hour and receive overtime pay for all hours worked in
excess of 40 hours,
 commission employees are paid a percentage of their sales
 base-salary-plus-commission employees receive a base salary plus a percentage of their sales.
For the current pay period, the company has decided to reward base-salary-plus-commission
employees by adding 10 percent to their base salaries.
 Manager works to assign the salary to Salaried employees. Assign Basic salary and per hour
wages to hourly employees. Assign percentage to commission employees and assign base salary,
commission percentage and bonus to base-salary-plus-commission employees.

1. Base class Employee is an abstract class and it should include data members representing the
name, address and social security number (SSN). It also includes virtual functions InsertData(),
PrintEmployee( ) and destructor.

2. Salaried is virtually inherited from class Employee. It has a static data member Salary(as it is
common for all the salaried employees). Include a static function SetSalary( ) to set salary value.
Override functions of InsertData() and PrintEmployee( ). In PrintEmployee( ) function Before
printing the employee data call CalculateSalary( ) function to calculate salary.

3. Hourly is virtually inherited from class Employee. It has a static data member
OvertimeSalaryPerHour and a non static data member hours. Include a static function
SetOvertimeSalary( ) to set OvertimeSalaryPerHour value. Override functions of InsertData(),
CalculateSalary( ) and PrintEmployee( ). In PrintEmployee( ) function Before printing the
employee data call CalculateSalary( ) function to calculate salary.

4. Commission is virtually inherited from class Employee. It has a static data member
CommissionRatio and a non static data member Sales. Include a static function
SetCommissionRatio( ) to set perecentage of the commission in CommissionRatio. Override
functions of InsertData(), CalculateSalary( ) and PrintEmployee( ). In PrintEmployee( ) function
Before printing the employee data call CalculateSalary( ) function to calculate salary.

5. Salary-plus-Commission is virtually inherited from class Employee. It has three static data
members Salary, CommissionRatio, BonusRatio. Initialize BonusRatio as 10. Include a non static
data member Sales as well. Include Three static functions SetCommissionRatio( ) and SetSalary( )
and SetBonusRatio( ) to set perecentage of the commission, bonus and basic salary of employee.
Override functions of InsertData(), CalculateSalary( ) and PrintEmployee( ). In PrintEmployee( )
function Before printing the employee data call CalculateSalary( ) function to calculate salary.

6. Manager is virtually inherited class from Salaried, Hourly, Commission and Salary-plus-
Commission classes. Override InsertData() function which calls all the static functions of parent

Object Oriented BS(SE)-2 SZABIST-ISB


Programming
ShaheedZulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT


classes to set their static values. Also override PrintEmployee( ) to print static data of all the
parent classes.
Write a test program in main and Apply Polymorphism using base class Employee pointer which
works dynamically (on user choice) for all types of employee(derived classes). Call InsertData()
and PrintEmployee( ) function for any type of object. Manager can only set and view all static
data members of all the classes while other employee can set their personal data and view all the
data including their calculated salary of that week. Your programs should run as long as user
wants (apply do while loop).
Solution

Object Oriented BS(SE)-2 SZABIST-ISB


Programming

You might also like