Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ An abstract class inherits class member property values and functions from a parent class but can have its own version(s) of member functions plus

C++

An abstract class inherits class member property values and functions from a parent class but can have its own version(s) of member functions plus its own individual class functions. The parent class may not have its own individual class members or can only serve as a base template for derived classes.

The base class, Employee, has the following class member values:

Employee ID (string such as AF201)

Hours (float)

Pay Per Hour (float)

Income Tax Rate (float such as 0.014, 0.022, 0.1)

Over time hours (float)

Employee Status (string such as Hourly, Salaried, Contractor)

Initialize (overloaded) functions for the Hourly, Salaried, Contractor

Member functions include:

SetID (pass a string to set the Employee ID for this class member)

SetHours (pass a float to set the Hours)

SetPay (pass a float to set the Pay Rate)

SetTaxRate (pass a float and set the Income Tax Rate for this class member)

SetStatus (pass a string to set the Employee Status)

getID (return Employee ID)

getHours (return Hours)

getPay (return Pay Per Hour)

getStatus (return Employee Status)

Employee Constructor (EmpID = N/A, numeric values = 0, Employee Status = N/A)

Virtual abstract function terminate

Virtual abstract function calculatepay

Virtual abstract function setovertime

Derived classes:

Hourly Class which its version of calculatepay:

Regular Pay (hours <= 40 hours) X Pay Rate

Overtime Pay (any hours > 40) X Pay Rate X 1.5

Gross Pay = Regular Pay + Overtime Pay

Taxes = Gross Pay X Tax Rate

Net Pay = Gross Taxes

Display Regular Hours, Overtime Hours (if any), Pay Rate

Display Regular Pay, Overtime Pay (if any)

Gross Pay, Taxes Withheld, Net Pay

Hourly has another function, Overtime

Determines Regular Hours and any Overtime Hours based on what the Hours were

If Hours <= 40 then Overtime Hours = 0

If Hours > 40 then Regular Hours = 40 and Overtime Hours = Hours 40

Reset Hours = 40

Salaried Class

Gross Pay = Pay Rate (represents Annual Salary)

Taxes Withheld = Gross Pay X Tax Rate

Net Pay = Gross Pay Taxes Withheld

Display Gross, Taxes and Net Pay

Contractor Class

Gross Pay = Pay Rate (represents contractor fee)

No income taxes withheld

ALL derived classes also have a terminate function

Set Hourly numeric values to 0, Keep Employee ID, set Empstatus = Hourly Terminated

Set Salaried numeric values to 0, Keep Employee ID, set Empstatus = Salaried Terminated

Set Contractor numeric values to 0, Keep Employee ID, set Empstatus = Contract Ended

Main includes:

Store class members into an array, one array for Hourly, one array for Salaried and a third array for Contractor members. Maximum of 10 class members per Employee type (i.e. up to 10 Hourly, 10 Salaried, 10 Contractors)

Allow user to:

Enter data for the Hourly (Employee ID, Total Hours Worked, Pay Rate, Income Tax Rate, Status (Hourly)

Enter data for the Salaried (Employee ID, Annual salary represented by Pay Rate, Income Tax Rate

Enter data for Contractor (Employee ID, Contractor Fee represented by Pay Rate

Set Class member Values into its array

Display the ID, Pay, Hours Tax, Net if any for Hourly

Display the ID, Annual Salary, Tax, Net for the Salaried

Display the ID, Contractor Fee for the Contractor

Terminate a derived class member Employee (Hourly, Salaried, Contractor)

Quit

Allow the user to enter as many class members up to 10 each in their individual array. Since we are using virtual functions, derived class members are accessed via pointers of type base (parent)

1 - Enter Data for Hourly Employees

2 - Enter Data for Salaried Employees

3 - Enter Data for Contractor Personnel

4 - Display Data for Hourly Employees

5 - Display Data for Salaried Employees

6 - Display Data for Contractor Personnel

7 - Terminate an Hourly Employee set Employee Status to Hourly - Terminated

8 - Terminate a Salaried Employee set Employee Status to Salaried Terminated

9 - Terminate a Contractor set Employee Status to Contract Ended

10 - Quit

Enter Option (1 - 10):

Initialize the first 3 Employee array locations for each Employee Type:

Hourly: (ID, Hours, Pay Rate, Tax rate)

ID: "AS101", Hours: 32.34, Pay Rate: $28.50, Tax Rate: 0.055

ID: "GH199", Hours: 44.5, Pay Rate: $39.22, Tax Rate: 0.04

ID: "UY189", Hours: 47.22, Pay Rate: $45.60, Tax Rate: 0.016

Salaried: (ID, Pay Rate, Tax rate)

ID: "VE320", Annual Salary: $45,750.34, Tax Rate: 0.07

ID: "BR003", Annual Salary: $65,740.88, Tax Rate: 0.065

ID: "AA891", Annual Salary: $50,900.71, Tax Rate: 0.12

Contractor: (ID, Pay Rate)

ID: "BV111", Contractor Fee: $55,473.56

ID: "NB290", Contractor Fee: $65,540.87

ID: "VC100", Contractor Fee: $45,679.25

There are two ways to hold class members in the array and access it. Which one you choose will decide the where the initialize functions are located.

An array of Hourly, an array of Salaried and an array of Contractors. Use a pointer of base class Employee to access each location of that array.

An array of base class pointers aimed at each derived class.

Hint: if you remove the virtual from the parent class and it still compiles and works.what you have is not a virtual

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions