Question: For this assignment, implement a class called Employee that will be used to hold the information for an employee. The Employee class The definition for

For this assignment, implement a class called Employee that will be used to hold the information for an employee.
The Employee class
The definition for the Employee class should be placed at the top of a CPP file while the constructor and methods should be written after the closing curly brace for int main().
Data Members
The data members for the class are:
an array of 30 characters to hold the employee's name
an array of 8 characters to hold the employee's identification number
a double to hold the employee's salary
Constructors
The default constructor (the constructor that takes no arguments) for the class should initialize the data members so that employee name is "None," the identification number is "ACB1234", and the salary is 0.00.
The other constructor for the class should initialize the data members using values that are passed to the constructor. It takes 3 arguments: an array of constant character with an employee name, an array of constant character with the employee identification number, and a double that holds the employee salary. Use the setIDnum and setSalary methods to initialize the identification number and salary, respectively. Use the strcpy function to initialize the name.
Methods
void display()
This method displays the employee information.
It takes no arguments and returns nothing.
The name and id number should be displayed on a single line. The salary should be displayed on the line below. The name should be left justified in a field 30 characters wide. The id number should be right justified in a field 10 characters wide. The salary should be displayed with two digits after the decimal point and a leading dollar sign. For example:
Barney Rubble NIU4865
$6782.40
void increaseSalary( double raise )
This method increases an employee's salary.
It takes one argument: a double that represents the amount to increase the employee's salary. It returns nothing.
If the passed in amount is invalid (less than or equal to 0), display an error message and do not make any changes to the employee's salary. If the passed in amount is valid, use it to increase the employee's salary.
void setIDnum( const char updated_id[])
This method changes an employee's identification number.
It takes one argument: an array of constant characters that holds the new employee identification number. It returns nothing.
Error checking is required. A valid identification number is exactly 7 characters in length. The first 3 characters must be alphabetic. The remaining 4 characters must be digits.
If the argument value is not exactly 7 characters in length, display an error message that the new identification number is not the correct length and do not make any change to the object. If the first 3 characters are not alphabetic, display an error message and do not make any change to the object. If the last 4 characters are not digits, display an error message and do not make any change to the object.
Once the argument has been validated, use it to change the identification number data member.
void setSalary( double updated_salary )
This method changes an employee's salary.
It takes one argument: a double that represents the new employee salary. It returns nothing.
If the passed in salary is less than or equal to 0, display an error message and do not make a change to the salary data member. Otherwise, update the employee's salary.
const char * getName()
This method returns an employee's name. It takes no arguments.
The return data type shown above indicates that an address of a character should be returned. This can be satisfied by returning the name of a character array.
const char * getIDnum()
This method returns an employee's identification number. It takes no arguments.
double getSalary()
This method returns an employee's salary. It takes no arguments.
int main()
The goal for int main() is to test the Employee class.
Create an Employee object using the constructor that takes 4 arguments. Use your name for the employee name (if you're pair programming, put both of your names - keep in mind the character limit and shorten the names if needed), an identification number of "NIU" and the last 4-digits from your z-number (if pair programming, use the last 4-digits for either of your z-numbers), and a salary of 53948.61.
Display the first Employee object with a label such as "The first Employee object", increase the salary by $125.15, and re-display the updated object.
Create a second Employee object. Use the default constructor.
Display the second Employee object with a label such as "The second Employee object", increase the salary by $-2200.00, and re-display the object.
Create a third Employee object. Use the constructor that takes 4 arguments. Use "Blanche Devereaux" for the employee name, an identification number of "TGG1985", and a salary of 820.12
Display the third Employee object with a label such as "The third Employee object", change the salary to $82.88, change

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 Finance Questions!