Question: Please Use C++ and Before u submite it Please chack it if it is work on both test1 and test2 case. Thanks!! 1.. Store the
Please Use C++ and Before u submite it Please chack it if it is work on both test1 and test2 case.
Thanks!!
1.. Store the data in Binary file and access it in Random Access mode.
2.Replace Class with Structure for Employee and Department.
3. Inside each structure, replace all string variables with array of characters.
4. Make Employee and Department editable. That means, the user should be able to edit a given Employee and Department. Youc an allow the user to edit Employee name, age etc and assign him/her to different department. Similarly department name and department head can be changed. However, do not allow the uesr to Employee ID in Employee file and Department ID in department file.
5. Please note that the data will no longer be stored in the array as it was in the midterm. Instead, it should be written to the file as soon as you collect the data from the user. If you are editing a record, read it from the file,collect new data from the user, store the record back to the file in the same place it was found inside the file. That means, the menu will not have options to save data to file or read data from file. Also, this should provide the ability for user to create unlimited number of employees and departments unlike in Midterm where you allowed only limited number of departments and employees.
You may use the following snippet of code which creates a new data file for employtee and Department if one does not already exist. Please note that the names of your data files must be departments.dat and employees,dat
fstream departments("departments.dat", ios::in |ios::out | ios::binary); if (departments.fail()) { departments.open("departments.dat", ios::out|ios::in | ios::binary| ios::trunc ); if (departments.fail()) { cout << "Error opening deparment file...."; return 0; } }
fstream employees("employees.dat", ios::in |ios::out | ios::binary); if (employees.fail()) { employees.open("employees.dat", ios::out|ios::in | ios::binary| ios::trunc ); if (employees.fail()) { cout << "Error opening employee file...."; return 0; } }
TEST CASE1: Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 1 Dept Name: Sales Head of Dept Name: Anna Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 1 Employee Name: John Employee Salary: $45000 Employee Age: 23 Department ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $45000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 2 Employee Name: Susan Employee Salary: $50000 Employee Age: 30 Department ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $95000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 2 Dept Name: Marketing Head of Dept Name: Marcus Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 3 Employee Name: Adam Employee Salary: $60000 Employee Age: 30 Department ID: 2 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $95000 Dept : Marketing Total Salary : $60000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 3 Which record to EDIT: Please choose one of the following... 1 to 2 : 2 Display Department Details: Dept ID : 2 Dept Name : Marketing Dept Head : Marcus EDIT the Department Data: Dept Name: Global Marketing Head of Dept Name: Butler Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $95000 Dept : Global Marketing Total Salary : $60000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 4 Which record to EDIT: Please choose one of the following... 1 to 3 : 3 Display Employee Details: ID : 3 Name : Adam Salary : $60000 Age : 30 Dept : 2 Edit the Employee Data: Employee Name: Adam Employee Salary: $75000 Employee Age: 31 Department ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $170000 Dept : Global Marketing Total Salary : $0 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 9 Please enter a valid choice (1 - 6): 6 Thank you, goodbye. TEST CASE2: Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 1 Dept Name: HumanResources Head of Dept Name: Maria Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 1 Please enter a unique Deptartment ID: 2 Dept Name: Marketing Head of Dept Name: Samy Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 1 Employee Name: John Employee Salary: $45000 Employee Age: 35 Department ID: 9 Please enter an existing Deptartment ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 1 Please enter a unique Employee ID: 2 Employee Name: Susan Employee Salary: $70000 Employee Age: 25 Department ID: 2 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : HumanResources Total Salary : $45000 Dept : Marketing Total Salary : $70000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 9 Please enter a valid choice (1 - 6): 6 Thank you, goodbye.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
