Question: (C++ CODE NEEDED) Write a class named Employee that has the following member variables: ? name: The name attribute holds an employees first and last

(C++ CODE NEEDED)

Write a class named Employee that has the following member variables:

? name: The name attribute holds an employees first and last name

? idNumber: The idNumber attribute is a string variable that holds an employees ID number

? department: The department attribute holds the name of the employees department

? position: The position attribute holds the name of the employees job title

? yearsWorked: This attribute holds the number of years the employee has worked at the company

The class should have the following overloaded constructors:

? A constructor that accepts the following values as arguments and assigns them to the appropriate data members (attributes): employees name and employees ID number, employees department, employees position, and the number of years the employee has worked at the company.

? A constructor that accepts the following values as arguments and assigns them to the appropriate data members (attributes): employees name and employees ID number. The department and position attributes should be initialized to the empty string () and the yearsWorked attribute should be initialized to zero.

? A default constructor (accepts no arguments) that initializes the name, idNumber, department, and position attributes to the empty string (). The yearsWorked attribute should be initialized to zero.

Write Get and Set methods for each attribute: name, idNumber, department, position, and yearsWorked. Do not allow the yearsWorked attribute to be set to values less than zero. If an attempt is made to set yearsWorked to less than zero, do not set the attribute and communicate the problem to the calling program. Remember that the class declaration (.h file) will contain the class attributes, function prototypes, and the function definitions. Name the class declaration file employee.h.

Next create a program to utilize the Employee class you created in the following manner: ? Declare 3 Employee objects o One with all 5 args included o One with only the first two args included o One with no args. Use set functions to set the missing values of the partially constructed objects. Demonstrate the error detection of the setyearsWorked function. Display the data for each of the three employees to the screen in similar to the table below (you do not need to display the lines in the table): Name ID Number Department Position Years Worked Jenny Jacobs JJ8990 Accounting President 15 Myron Smith MS7571 IT Programmer 5 Chris Raines CR6873 Manufacturing Engineer 30 2018 3 The program utilizing the employee class should be in a separate .cpp file. Name this program employeeTest.cpp (dont forget to include the employee.h file).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!