Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

redo program 1(what I have type on bottom to meet the following requirements) it must not interact with the user to receive inputs for efficiency

redo program 1(what I have type on bottom to meet the following requirements) it must not interact with the user to receive inputs for efficiency in testing programs, while meeting the following requirements. in c++

  1. Employee class
  2. 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.
  3. 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
  1. Prevent multiple inclusion of the Employee class by adding preprocessor directive: ifndef, define, endif
  2. Have the class declaration in .h and define all member functions in .cpp
  3. main() : use and test the Employee class
  4. 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.

  1. Display information of all employees on the console
  2. Display the average salary of all employees on the console
  3. Display information of programmers only on the console
  4. Increase the salaries of all managers by random percentage and display the results
  5. Reassign an employee to a different department and role with increased salary and display the result.
  6. Create another employee with a parameter constructor and display the employee information.
  7. Also, display the number of employees.
  8. Release any dynamically allocated memory in your program without memory leak
  9. 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.
  10. Apply indentations correctly to make your program readable.
  11. makefile

Provide makefile to apply separate compilation

my program one was --

#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<<" Average Salary: " << avgSal/size; return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions