Question
C++ please write a program that compiles and run. PA1 program is below: In this project, you will modify PA1 by creating Employee class and
C++ please write a program that compiles and run. PA1 program is below:
In this project, you will modify PA1 by creating Employee class and apply separate compilation. Your program must not interact with the user to receive inputs for efficiency in testing programs, while meeting the following requirements.
Employee class
Change the struct data type Employee to a class with all preexisting attributes(, or data members, or data fields) and an additional data member named count that keeps track of the number of Employee objects.
Implement the interface that include the following functionalities
An Employee object can be created with its data members set to default values
An Employee object can be created with its data members set to values according to parameters.
An Employee object notifies being out of scope when it is.
Each data member can be retrieved
department and role can be set individually
salary can be increased by 5 - 10 %
department, role and salary can be changed simultaneously.
All data members can be displayed at once
Prevent accidental modification of data members if unnecessary
Prevent multiple inclusion of the Employee class by adding preprocessor directive: ifndef, define, endif
Have the class declaration in .h and define all member functions in .cpp
main() : use and test the Employee class
Create an employee DB with 5 employees by using dynamic array allocation
Before moving to b, make sure that each employee is unique. For this, you can manipulate data members of an employee with your choice.
Display information of all employees on the console
Display the average salary of all employees on the console
Display information of programmers only on the console
Increase the salaries of all managers by random percentage and display the results
Reassign an employee to a different department and role with increased salary and display the result.
Create another employee with a parameter constructor and display the employee information.
Also, display the number of employees.
Release any dynamically allocated memory in your program without memory leak
Reset any pointer variable if it is not used any longer. Otherwise, such pointer becomes a dangling pointer pointing to a memory that has been deleted already.
Apply indentations correctly to make your program readable.
makefile
Provide makefile to apply separate compilation
PROGRAM: PA1 is here from CHEGG:
/* * C++ program to manage employee database */ #include#include #include #include #include using namespace std; #define SIZE 5 enum Role { programmer = 0, manager = 1, director = 2 }; struct Employee { string firstName; string lastName; int SSN; string department; Role role; double salary; }; void setSalaries(Employee *em, int size) { for(int i = 0; i < size; i++) { em[i].salary = rand(); } } void setRoles(Employee *em, int size) { for(int i = 0; i < size; i++) { em[i].role = Role(rand()%3); } } string getRole(Role role) { string ret; switch(role) { case 0 : ret = "Programmer"; break; case 1 : ret = "Manager"; break; case 2 : ret = "Director"; break; } return ret; } void hardCoding(Employee *em) { em[0].firstName = "Bob"; em[0].lastName = "Marley"; em[0].department = "Acc."; em[0].SSN = 3; em[1].firstName = "Shas"; em[1].lastName = "Ivy"; em[1].department = "Audit"; em[1].SSN = 4; em[2].firstName = "Margo"; em[2].lastName = "Kim"; em[2].department = "Mgmnt."; em[2].SSN = 5; em[3].firstName = "Milly"; em[3].lastName = "Pink"; em[3].department = "IT"; em[3].SSN = 6; em[4].firstName = "Sia"; em[4].lastName = "Miskel"; em[4].department = "IT"; em[4].SSN = 7; } int main() { Employee *emp = new Employee[SIZE]; srand(time(NULL)); double avgSal = 0.0; hardCoding(emp); setSalaries(emp, SIZE); setRoles(emp, SIZE); cout<<"Employee Database "; cout<<"Name\t\tSSN\tDapartment\tRole\t\tSalary "; for(int i = 0; i < SIZE; i++) { cout<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started