Question
C++ Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The
C++
Write a program to allow the user to:
1. Create two classes. Employee and Departments.
The Department class will have: DepartmentID, Departmentname, DepartmentHeadName.
The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID.
Both of the above classes should have appropriate constructors, accessor methods.
2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3.
Your program should display a menu for the user to do the following:
1. Create Department. Collect all information about a department. Make sure the department ID does not already exist in the array containing Department objects. If it does not, then insert the Department object into the array. When the array is full, display the error message to the user "The array is full, you can not add any more departments"
2. Create Employee. Collect all information about an Employee. Make sure the Employee ID does not already exist in the array containing Employee objects. If it does not, then insert the Employee object into the array. Also make sure that the DepartmentID that the employee belongs also exists. If it does not, then display error message. When the array is full, display the error message to the user "The array is full, you can not add any more Employees"
3. Write the data to the file. When the user selects this option, dump the information in each array into a separate file.
4. Retrieve data from file. When user selects this option, open each file, load the data from the file into the appropriate array.
5. Display Report: When user selects this option, go through arrays and display the total salary paid for each department. The report should display the department name and the total salary of all employees in that department.
output has to be the same:
TEST CASE1: 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Please Enter Department Details: Department ID : 1 Department Name : Sales Head of Department : Anna 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Please Enter Department Details: Department ID : 1 Value must be unique! 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Please Enter Department Details: Department ID : 2 Department Name : Marketing Head of Department : Mark 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Please Enter Department Details: Department ID : 3 Department Name : GlobalSales Head of Department : Patil 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 The array is full, you can not add any more Departments. 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 1 Employee Name :John Salary: $45000 Age : 25 Department ID : 1 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 1 Value must be unique! 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 The array is full, you can not add any more Departments. 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 2 Employee Name :Susan Salary: $45000 Age : 26 Department ID : 1 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 3 Employee Name :Adam Salary: $50000 Age : 24 Department ID : 2 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 4 Employee Name :Manny Salary: $60000 Age : 26 Department ID : 2 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 5 Employee Name :Maria Salary: $60000 Age : 23 Department ID : 9 Please enter a valid department ID: 3 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 The array is full, you can not add any more Employees. 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $90000 Dept : Marketing Total Salary : $110000 Dept : GlobalSales Total Salary : $60000 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 9 Please enter a valid choice (1 - 6): 3 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 6 Thank you, goodbye. TEST CASE 2: 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Please Enter Department Details: Department ID : 1 Department Name : Sales Head of Department : Markus 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Please Enter Department Details: Department ID : 1 Value must be unique! 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Please Enter Department Details: Department ID : 2 Department Name : Marketing Head of Department : Anna 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 1 Employee Name :John Salary: $45000 Age : 23 Department ID : 1 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 2 Employee Name :Susan Salary: $40000 Age : 45 Department ID : 1 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Please Enter Employee Details: Employee ID : 3 Employee Name :many Salary: $70000 Age : 34 Department ID : 2 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $85000 Dept : Marketing Total Salary : $70000 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 3 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 4 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $85000 Dept : Marketing Total Salary : $70000 1. Create Department 2. Create Employee 3. Write Out Data File 4. Read In Data File 5. Display Salary Report 6. -- Quit -- Please make a selection : 6 Thank you, goodbye.
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