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 characters to hold the employee's name
an array of 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 "ACB and the salary is
The other constructor for the class should initialize the data members using values that are passed to the constructor. It takes 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 characters wide. The id number should be right justified in a field characters wide. The salary should be displayed with two digits after the decimal point and a leading dollar sign. For example:
Barney Rubble NIU
$
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 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 updatedid
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 characters in length. The first characters must be alphabetic. The remaining characters must be digits.
If the argument value is not exactly 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 characters are not alphabetic, display an error message and do not make any change to the object. If the last 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 updatedsalary
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 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 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 digits from your znumber if pair programming, use the last digits for either of your znumbers and a salary of
Display the first Employee object with a label such as "The first Employee object", increase the salary by $ and redisplay 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 $ and redisplay the object.
Create a third Employee object. Use the constructor that takes arguments. Use "Blanche Devereaux" for the employee name, an identification number of TGG and a salary of
Display the third Employee object with a label such as "The third Employee object", change the salary to $ change
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
