Question
PA1 ----- #include #include #include #include using namespace std; enum Role {programmer, manager, director}; struct Employee { string firstName; string lastName; int SSN; string department;
PA1 -----
#include
#include
#include
#include
using namespace std;
enum Role {programmer, manager, director};
struct Employee {
string firstName;
string lastName;
int SSN;
string department;
Role role;
double salary;
};
//function prototypes
void fillArray(Employee*, int);
void setSalaries(Employee*, int);
void setRoles(Employee*, int);
double avgSalary(Employee*, int);
int main() {
//srand to reset runtime for random values
srand(time(NULL));
const int SIZE = 5;
//declares dynamic array with pointer p at first element
Employee* p = new Employee[SIZE];
//call functions
fillArray(p, SIZE);
setSalaries(p, SIZE);
setRoles(p, SIZE);
double average = avgSalary(p, SIZE);
//console employee data
for(int i = 0; i
cout
cout
cout
cout
if (p[i].role == 0)
cout
if (p[i].role == 1)
cout
if (p[i].role == 2)
cout
cout
} //close for loop
//console average salary
cout
cout
//console programmer only data
cout
for(int i = 0; i
if (p[i].role == 0) {
cout
cout
cout
cout
cout
}//close if statement
}//close loop
//delete dynamic memory and reset pointer
delete[] p;
p = NULL;
p[1].SSN = 222222222;
p[1].department = "Systems";
p[2].firstName = "Heather";
p[2].lastName = "Willingham";
p[2].SSN = 333333333;
p[2].department = "Systems";
p[3].firstName = "Cory";
p[3].lastName = "Shields";
p[3].SSN = 444444444;
p[3].department = "Systems";
p[4].firstName = "Adrien";
p[4].lastName = "Smith";
p[4].SSN = 555555555;
p[4].department = "Systems";
}//close fillArray
void setSalaries(Employee* p, int size) {
for(int i = 0; i
p[i].salary = rand() % 75000 + 45000;
} //close setSalaries
void setRoles(Employee* p, int size) {
for(int i = 0; i
p[i].role = Role(rand() % 3);
} //close setRoles
double avgSalary(Employee* p, int size) {
double sum = 0;
for(int i = 0; i
sum += p[i].salary;
double average = sum/size;
return average;
}//close avgSalvoid
Project description 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. 1. Employee class a. Change the struct data type Employee to a class with all preexisting attibutesl 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 b. c. Prevent multiple inclusion of the Employee class by adding preprocessor directive: ifndef define eadif d. Have the class declaration in .h and define all member functions in cpR 2. main0 use and test the Employee clas a. 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. b. Display information of all employees on the console c. Display the average salary of all employees on the console d. Display information of programmers only on the console e. Increase the salaries of all managers by random percentage and display the results f Reassign an employee to a different department and role with increased salary and display the result. g. Create another employee with a parameter constructor and display the employee information. h. Also, display the number of employees. i. Release any dynamically allocated memory in your program without memory leak j. 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 correctly to make y k. Apply indentations ec our program readable. 3. makefile Provide makefle to apply separate compilationStep 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