SlideShare a Scribd company logo
1 of 16
//Classes(or Libraries)
#include
#include
#include
#include
#include
//Used to shorten console commands
using namespace std;
//Programmer defined encapsulation of data and functions
class Department
{
private:
string DepartmentName, DepartmentHeadName, DepartmentID;
public:
// Constructors
Department()
{
}
Department(string id, string name)
{
DepartmentID = id;
DepartmentName = name;
DepartmentHeadName = "";
}
Department(string id, string name, string hn)
{
DepartmentID = id;
DepartmentName = name;
DepartmentHeadName = hn;
}
//Setter and getters(Accsesors)
string getDepId()
{
return DepartmentID;
}
string getDepartmentName()
{
return DepartmentName;
}
string getDepHeadName()
{
return DepartmentHeadName;
}
void setDepId(string DepId)
{
DepartmentID = DepId;
}
void setDepName(string DepName)
{
DepartmentName = DepName;
}
void setDepHead(string DepHead)
{
DepartmentHeadName = DepHead;
}
};
//Programmer defined encapsulation of data and functions
class Employee
{
private:
string employeename, employeeID, employeeDepartmentID;
int employeeage;
doubleemployeesalary;
public:
// constructors
Employee() {}
Employee(string id, string name)
{
employeeID = id;
employeename = name;
}
Employee(string id, string name, int age)
{
employeeID = id;
employeename = name;
employeeage = age;
}
Employee(string id, string name, int age, double salary)
{
employeeID = id;
employeename = name;
employeeage = age;
employeesalary = salary;
}
Employee(string id, string name, int age, double salary, string
departmentid)
{
employeeID = id;
employeename = name;
employeeage = age;
employeesalary = salary;
employeeDepartmentID = departmentid;
}
// Accessors
string getEmpID()
{
return employeeID;
}
string getEmpName()
{
return employeename;
}
string getEmpDepID()
{
return employeeDepartmentID;
}
int getEmpAge()
{
return employeeage;
}
double getEmpSal()
{
return employeesalary;
}
void setEmpID(string empId)
{
employeeID = empId;
}
void setEmpName(string empName)
{
employeename = empName;
}
void setEmpDepID(string empDepId)
{
employeeDepartmentID = empDepId;
}
void setEmpAge(int empAge)
{
employeeage = empAge;
}
void setEmpSalary(double empsal)
{
employeesalary = empsal;
}
};
//Function prototypes
void ShowMenu();
void choices();
int main()
{
ShowMenu();
choices();
return 0;
}
//Display Function
void ShowMenu()
{
cout << "nnn";
cout << "1-Create Departmentn";
cout << "2-Creat employeen";
cout << "3-Write the data to the filen";
cout << "4-Retrive the data from the filen";
cout << "5-Display Reportn";
cout << "6-Exitn n n";
}
// Choice function
void choices()
{
// Creating array objects
Department dep[3];
Employee emp[7];
string depid, empid, empdepid, depname, dephead, empname,
depnamefile, depdeadfile;
int empage;
double empsalary;
int choice;
ifstream file_in, file_in2;
ofstream file_out, file_out2;
char again; //Used to loop the entire program
int counter, empcounter, depcounter;
bool id3 = false;
int a; //used for getting age from file
double s; //used for getting salarry from file
string info; // getting lines from file
size_t pos; //position
double sal1, sal2, sal3; //Salaries for calculation
do {
cout << "Please enter a number from the menu:";
cin >> choice;
switch (choice)
{
case 1:
cout << "Please enter Department ID:";
cin >> depid;
//Loop to not get a duplicate
for (int i = 0; i < 3; i++)
{
while (dep[i].getDepId() == depid)
{
cout << "The Department ID that you entered exist. Try again:";
cin >> depid;
}
}
//Condition to make sure not over arrays
if (depcounter < 3)
{
cout << "Please enter the department name:";
cin >> depname;
cout << "Please enter the department head:";
cin >> dephead;
dep[depcounter].setDepId(depid);
dep[depcounter].setDepName(depname);
dep[depcounter].setDepHead(dephead);
depcounter++;
}
else
cout << "Array is full.n";
ShowMenu();
break;
case 2:
cout << "Please enter the employee ID:";
cin >> empid;
//Loop to not get duplicate
for (int i = 0; i < 7; i++)
{
while (emp[i].getEmpID() == empid)
{
cout << "The Employee ID that you entered exist. Try again:";
cin >> empid;
}
}
//condition to not go over arrays sizes
if (empcounter < 7) {
cout << "Please enter the employee department ID:";
cin >> empdepid;
for (int i = 0; i < 7; i++)
{
if (dep[i].getDepId() == empdepid)
{
id3 = true;
break;
}
}
if (id3)
{
cout << "Please enter the employee Name:";
cin >> empname;
cout << "Please enter the employee Age:";
cin >> empage;
cout << "Please enter the employee salary:";
cin >> empsalary;
emp[empcounter].setEmpID(empid);
emp[empcounter].setEmpName(empname);
emp[empcounter].setEmpDepID(empdepid);
emp[empcounter].setEmpAge(empage);
emp[empcounter].setEmpSalary(empsalary);
empcounter++;
}
else
cout << "Department not foundn";
}
else
cout << "Array is full.n";
ShowMenu();
break;
case 3:
//condition to mmake sure objects are compelted, the
write to file
if (depcounter == 3 && empcounter == 7)
{
file_out.open("dep.txt");
for (int counter = 0; counter < 3; counter++)
{
file_out << "Department ID: " << dep[counter].getDepId() <<
endl;
file_out << "Department Name: " <<
dep[counter].getDepartmentName() << endl;
file_out << "Department Head Name: " <<
dep[counter].getDepHeadName() << endl;
file_out << endl << endl;
}
file_out.close();
file_out2.open("emp.txt");
for (int counter = 0; counter < 7; counter++)
{
file_out2 << "Employee ID: " << emp[counter].getEmpID() <<
endl;
file_out2 << "Employee Name: " <<
emp[counter].getEmpName() << endl;
file_out2 << "Employee Age: " << emp[counter].getEmpAge()
<< endl;
file_out2 << "Employee Salary: " << emp[counter].getEmpSal()
<< endl;
file_out2 << "Employee Department ID: " <<
emp[counter].getEmpDepID() << endl;
file_out2 << endl << endl;
}
//Making sure user doesn't close the program without
saving data
cout << "File not saved. Do you want to save the file? (Y/N)n";
cin >> again;
if (toupper(again) == 'Y')
file_out.close();
file_out2.close();
}
else
cout << "Arrays not complete. Can't write into files.n" << endl
<< endl;
ShowMenu();
break;
case 4:
file_in.open("dep.txt");
if (file_in)
{
int counter;
// getting department data from file
while (getline(file_in, info) && counter < 3)
{
pos = info.find(": ");
dep[counter].setDepId(info.substr(pos + 2));
getline(file_in, info);
pos = info.find(": ");
dep[counter].setDepName(info.substr(pos + 2));
getline(file_in, info);
pos = info.find(": ");
dep[counter].setDepHead(info.substr(pos + 2));
getline(file_in, info);
getline(file_in, info);
counter++;
}
file_in.close();
}
else cout << "File Dep not found." << endl;
file_in2.open("emp.txt");
if (file_in2)
{
int counter;
//getting employee data from file
while (getline(file_in2, info) && counter < 7)
{
pos = info.find(": ");
emp[counter].setEmpID(info.substr(pos + 2));
getline(file_in2, info);
pos = info.find(": ");
emp[counter].setEmpName(info.substr(pos + 2));
getline(file_in2, info);
pos = info.find(": ");
istringstream flow(info.substr(pos + 2));
flow >> a;
emp[counter].setEmpAge(a);
getline(file_in2, info);
pos = info.find(": ");
istringstream flow1(info.substr(pos + 2));
flow1 >> s;
emp[counter].setEmpSalary(s);
getline(file_in2, info);
pos = info.find(": ");
emp[counter].setEmpDepID(info.substr(pos + 2));
getline(file_in2, info);
getline(file_in2, info);
counter++;
}
file_in2.close();
}
else cout << "File Emp not found." << endl;
ShowMenu();
break;
case 5:
//Linear search through arrays
for (int i = 0; i < 7; i++)
{
if (emp[i].getEmpDepID() == dep[0].getDepId())
{
sal1 = sal1 + emp[i].getEmpSal();
}
if (emp[i].getEmpDepID() == dep[1].getDepId())
{
sal2 = sal2 + emp[i].getEmpSal();
}
if (emp[i].getEmpDepID() == dep[2].getDepId())
{
sal3 = sal3 + emp[i].getEmpSal();
}
}
//displaying report
cout << showpoint << fixed << setprecision(2);
cout << "DepartmenttSalaryreportn";
cout << dep[0].getDepartmentName() << "tt" << sal1 << "n";
cout << dep[1].getDepartmentName() << "tt" << sal2 << "n";
cout << dep[2].getDepartmentName() << "tt" << sal3 << "n";
ShowMenu();
break;
case 6:
cout << "Exiting the program. Thank you." << endl;
break;
default:
cout << "Invalid selection. Please Try again" << endl;
ShowMenu();
break;
}
} while (choice != 6);
}
The purpose of this project is to take your Midterm project and
implement it using Random Access Binary Files.
As you recall, the Midterm project used text files to store the
data. Here in the final exam project,
you will be storing the data in Random Access Binary File.
Also, in the Midterm project you used Arrays to temporarily
hold the data in the memory until the user
decides to write the data to file. Here you will not be using
Arrays and instead writing the
data directly to Random Access Binary File. Please read the
chapter Advance File and I/O operations
before attempting this.
Here is the full description of the Final exam project.
Modify your Midterm Exam Project to:
1. Replace Employee and Department classes with Employee
and Department Structures.
2. Inside each structure, replace all string variables with array
of characters.
3. Make Employee and Department editable. That means, the
user should be able to edit a given Employee and Department.
4. Do not allow the user to edit the Employee ID and
Department ID.
5. Use Random Access Files to store the data in Binary Form.
This means, you should not use an Arrays to
store the data in the memory. Instead, when the user wants to
create a new Employee/Department,
you write it to the file right away. Also when the user says
he/she wants to edit
an Employee/Department, ask the user to enter
EmployeeID/DepartmentID.
Read the data from the file and display it to the user.
Allow the user to enter new data and write it back to the file in
the same position inside the file.
Please read the chapter . Advance File/IO operations which has
examples on how to do this.
Classes(or Libraries)#include #include #include #include.docx

More Related Content

Similar to Classes(or Libraries)#include #include #include #include.docx

in C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdfin C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdfadithyaups
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docxAustinaGRPaigey
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfyamew16788
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxjoellemurphey
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfSANDEEPARIHANT
 
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdfexxonzone
 
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfProgramming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfssuser6254411
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfRahul04August
 
Student Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docxStudent Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docxflorriezhamphrey3065
 
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxInstruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxcarliotwaycave
 
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docxAssignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docxbraycarissa250
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxSirRafiLectures
 

Similar to Classes(or Libraries)#include #include #include #include.docx (20)

in C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdfin C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdf
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
Operator overload rr
Operator overload  rrOperator overload  rr
Operator overload rr
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docx
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdf
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
 
12Structures.pptx
12Structures.pptx12Structures.pptx
12Structures.pptx
 
COW
COWCOW
COW
 
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfProgramming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
 
Pl sql using_xml
Pl sql using_xmlPl sql using_xml
Pl sql using_xml
 
Student Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docxStudent Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docx
 
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxInstruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
 
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docxAssignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
Computer Programming- Lecture 10
Computer Programming- Lecture 10Computer Programming- Lecture 10
Computer Programming- Lecture 10
 

More from brownliecarmella

E C O N F O C U S T H I R D Q U A R T E R 2 0 1 3 31.docx
E C O N F O C U S   T H I R D Q U A R T E R   2 0 1 3 31.docxE C O N F O C U S   T H I R D Q U A R T E R   2 0 1 3 31.docx
E C O N F O C U S T H I R D Q U A R T E R 2 0 1 3 31.docxbrownliecarmella
 
E B B 3 5 9 – E B B S P o r t f o l i o V C o u r.docx
E B B 3 5 9  –  E B B S  P o r t f o l i o  V  C o u r.docxE B B 3 5 9  –  E B B S  P o r t f o l i o  V  C o u r.docx
E B B 3 5 9 – E B B S P o r t f o l i o V C o u r.docxbrownliecarmella
 
e activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docx
e activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docxe activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docx
e activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docxbrownliecarmella
 
Dynamics of Human Service Program ManagementIndividuals who .docx
Dynamics of Human Service Program ManagementIndividuals who .docxDynamics of Human Service Program ManagementIndividuals who .docx
Dynamics of Human Service Program ManagementIndividuals who .docxbrownliecarmella
 
Dynamic Postural Assessment Name _____________________.docx
Dynamic Postural Assessment Name _____________________.docxDynamic Postural Assessment Name _____________________.docx
Dynamic Postural Assessment Name _____________________.docxbrownliecarmella
 
Dylan (age 45, Caucasian) is a heroin addict who has been in and o.docx
Dylan (age 45, Caucasian) is a heroin addict who has been in and o.docxDylan (age 45, Caucasian) is a heroin addict who has been in and o.docx
Dylan (age 45, Caucasian) is a heroin addict who has been in and o.docxbrownliecarmella
 
Dustin,A case study is defined by Saunders, Lewis, and Thornhi.docx
Dustin,A case study is defined by Saunders, Lewis, and Thornhi.docxDustin,A case study is defined by Saunders, Lewis, and Thornhi.docx
Dustin,A case study is defined by Saunders, Lewis, and Thornhi.docxbrownliecarmella
 
DWPM    71713  1  543707.1  MEMBERSHIP A.docx
DWPM    71713  1  543707.1  MEMBERSHIP A.docxDWPM    71713  1  543707.1  MEMBERSHIP A.docx
DWPM    71713  1  543707.1  MEMBERSHIP A.docxbrownliecarmella
 
DwightEvaluation       Leadership style assessments certainl.docx
DwightEvaluation       Leadership style assessments certainl.docxDwightEvaluation       Leadership style assessments certainl.docx
DwightEvaluation       Leadership style assessments certainl.docxbrownliecarmella
 
Dwight Waldo is known for his work on the rise of the administrative.docx
Dwight Waldo is known for his work on the rise of the administrative.docxDwight Waldo is known for his work on the rise of the administrative.docx
Dwight Waldo is known for his work on the rise of the administrative.docxbrownliecarmella
 
Dwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docx
Dwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docxDwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docx
Dwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docxbrownliecarmella
 
DVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docx
DVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docxDVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docx
DVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docxbrownliecarmella
 
Dusk of DawnDiscussion questions1. Explain when we call fo.docx
Dusk of DawnDiscussion questions1. Explain when we call fo.docxDusk of DawnDiscussion questions1. Explain when we call fo.docx
Dusk of DawnDiscussion questions1. Explain when we call fo.docxbrownliecarmella
 
Durst et al. (2014) describe the burden that some Romani experience .docx
Durst et al. (2014) describe the burden that some Romani experience .docxDurst et al. (2014) describe the burden that some Romani experience .docx
Durst et al. (2014) describe the burden that some Romani experience .docxbrownliecarmella
 
DuringWeek 4, we will shift our attention to the legislative.docx
DuringWeek 4, we will shift our attention to the legislative.docxDuringWeek 4, we will shift our attention to the legislative.docx
DuringWeek 4, we will shift our attention to the legislative.docxbrownliecarmella
 
DuringWeek 3, we will examine agenda setting in more depth w.docx
DuringWeek 3, we will examine agenda setting in more depth w.docxDuringWeek 3, we will examine agenda setting in more depth w.docx
DuringWeek 3, we will examine agenda setting in more depth w.docxbrownliecarmella
 
During  the course of this class you have learned that Latin Ameri.docx
During  the course of this class you have learned that Latin Ameri.docxDuring  the course of this class you have learned that Latin Ameri.docx
During  the course of this class you have learned that Latin Ameri.docxbrownliecarmella
 
During WW II, the Polish resistance obtained the German encoding mac.docx
During WW II, the Polish resistance obtained the German encoding mac.docxDuring WW II, the Polish resistance obtained the German encoding mac.docx
During WW II, the Polish resistance obtained the German encoding mac.docxbrownliecarmella
 
During Week 5, we studied social stratification and how it influence.docx
During Week 5, we studied social stratification and how it influence.docxDuring Week 5, we studied social stratification and how it influence.docx
During Week 5, we studied social stratification and how it influence.docxbrownliecarmella
 
During this week you worked with the main concepts of Set Theory. Ch.docx
During this week you worked with the main concepts of Set Theory. Ch.docxDuring this week you worked with the main concepts of Set Theory. Ch.docx
During this week you worked with the main concepts of Set Theory. Ch.docxbrownliecarmella
 

More from brownliecarmella (20)

E C O N F O C U S T H I R D Q U A R T E R 2 0 1 3 31.docx
E C O N F O C U S   T H I R D Q U A R T E R   2 0 1 3 31.docxE C O N F O C U S   T H I R D Q U A R T E R   2 0 1 3 31.docx
E C O N F O C U S T H I R D Q U A R T E R 2 0 1 3 31.docx
 
E B B 3 5 9 – E B B S P o r t f o l i o V C o u r.docx
E B B 3 5 9  –  E B B S  P o r t f o l i o  V  C o u r.docxE B B 3 5 9  –  E B B S  P o r t f o l i o  V  C o u r.docx
E B B 3 5 9 – E B B S P o r t f o l i o V C o u r.docx
 
e activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docx
e activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docxe activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docx
e activityhttpsblackboard.strayer.edubbcswebdavinstitutionBU.docx
 
Dynamics of Human Service Program ManagementIndividuals who .docx
Dynamics of Human Service Program ManagementIndividuals who .docxDynamics of Human Service Program ManagementIndividuals who .docx
Dynamics of Human Service Program ManagementIndividuals who .docx
 
Dynamic Postural Assessment Name _____________________.docx
Dynamic Postural Assessment Name _____________________.docxDynamic Postural Assessment Name _____________________.docx
Dynamic Postural Assessment Name _____________________.docx
 
Dylan (age 45, Caucasian) is a heroin addict who has been in and o.docx
Dylan (age 45, Caucasian) is a heroin addict who has been in and o.docxDylan (age 45, Caucasian) is a heroin addict who has been in and o.docx
Dylan (age 45, Caucasian) is a heroin addict who has been in and o.docx
 
Dustin,A case study is defined by Saunders, Lewis, and Thornhi.docx
Dustin,A case study is defined by Saunders, Lewis, and Thornhi.docxDustin,A case study is defined by Saunders, Lewis, and Thornhi.docx
Dustin,A case study is defined by Saunders, Lewis, and Thornhi.docx
 
DWPM    71713  1  543707.1  MEMBERSHIP A.docx
DWPM    71713  1  543707.1  MEMBERSHIP A.docxDWPM    71713  1  543707.1  MEMBERSHIP A.docx
DWPM    71713  1  543707.1  MEMBERSHIP A.docx
 
DwightEvaluation       Leadership style assessments certainl.docx
DwightEvaluation       Leadership style assessments certainl.docxDwightEvaluation       Leadership style assessments certainl.docx
DwightEvaluation       Leadership style assessments certainl.docx
 
Dwight Waldo is known for his work on the rise of the administrative.docx
Dwight Waldo is known for his work on the rise of the administrative.docxDwight Waldo is known for his work on the rise of the administrative.docx
Dwight Waldo is known for his work on the rise of the administrative.docx
 
Dwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docx
Dwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docxDwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docx
Dwayne and Debbie Tamai Family of Emeryville, Ontario.Mr. Dw.docx
 
DVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docx
DVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docxDVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docx
DVWASetting up DAMN VULNERABLE WEB APPLICATIONSDam.docx
 
Dusk of DawnDiscussion questions1. Explain when we call fo.docx
Dusk of DawnDiscussion questions1. Explain when we call fo.docxDusk of DawnDiscussion questions1. Explain when we call fo.docx
Dusk of DawnDiscussion questions1. Explain when we call fo.docx
 
Durst et al. (2014) describe the burden that some Romani experience .docx
Durst et al. (2014) describe the burden that some Romani experience .docxDurst et al. (2014) describe the burden that some Romani experience .docx
Durst et al. (2014) describe the burden that some Romani experience .docx
 
DuringWeek 4, we will shift our attention to the legislative.docx
DuringWeek 4, we will shift our attention to the legislative.docxDuringWeek 4, we will shift our attention to the legislative.docx
DuringWeek 4, we will shift our attention to the legislative.docx
 
DuringWeek 3, we will examine agenda setting in more depth w.docx
DuringWeek 3, we will examine agenda setting in more depth w.docxDuringWeek 3, we will examine agenda setting in more depth w.docx
DuringWeek 3, we will examine agenda setting in more depth w.docx
 
During  the course of this class you have learned that Latin Ameri.docx
During  the course of this class you have learned that Latin Ameri.docxDuring  the course of this class you have learned that Latin Ameri.docx
During  the course of this class you have learned that Latin Ameri.docx
 
During WW II, the Polish resistance obtained the German encoding mac.docx
During WW II, the Polish resistance obtained the German encoding mac.docxDuring WW II, the Polish resistance obtained the German encoding mac.docx
During WW II, the Polish resistance obtained the German encoding mac.docx
 
During Week 5, we studied social stratification and how it influence.docx
During Week 5, we studied social stratification and how it influence.docxDuring Week 5, we studied social stratification and how it influence.docx
During Week 5, we studied social stratification and how it influence.docx
 
During this week you worked with the main concepts of Set Theory. Ch.docx
During this week you worked with the main concepts of Set Theory. Ch.docxDuring this week you worked with the main concepts of Set Theory. Ch.docx
During this week you worked with the main concepts of Set Theory. Ch.docx
 

Recently uploaded

Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 

Recently uploaded (20)

Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 

Classes(or Libraries)#include #include #include #include.docx

  • 1. //Classes(or Libraries) #include #include #include #include #include //Used to shorten console commands using namespace std; //Programmer defined encapsulation of data and functions class Department { private: string DepartmentName, DepartmentHeadName, DepartmentID; public: // Constructors Department() { } Department(string id, string name) { DepartmentID = id; DepartmentName = name; DepartmentHeadName = ""; } Department(string id, string name, string hn) { DepartmentID = id; DepartmentName = name; DepartmentHeadName = hn; }
  • 2. //Setter and getters(Accsesors) string getDepId() { return DepartmentID; } string getDepartmentName() { return DepartmentName; } string getDepHeadName() { return DepartmentHeadName; } void setDepId(string DepId) { DepartmentID = DepId; } void setDepName(string DepName) { DepartmentName = DepName; } void setDepHead(string DepHead) { DepartmentHeadName = DepHead; } };
  • 3. //Programmer defined encapsulation of data and functions class Employee { private: string employeename, employeeID, employeeDepartmentID; int employeeage; doubleemployeesalary; public: // constructors Employee() {} Employee(string id, string name) { employeeID = id; employeename = name; } Employee(string id, string name, int age) { employeeID = id; employeename = name; employeeage = age; } Employee(string id, string name, int age, double salary) { employeeID = id; employeename = name; employeeage = age; employeesalary = salary; } Employee(string id, string name, int age, double salary, string departmentid) { employeeID = id; employeename = name;
  • 4. employeeage = age; employeesalary = salary; employeeDepartmentID = departmentid; } // Accessors string getEmpID() { return employeeID; } string getEmpName() { return employeename; } string getEmpDepID() { return employeeDepartmentID; } int getEmpAge() { return employeeage; } double getEmpSal() { return employeesalary; } void setEmpID(string empId) { employeeID = empId; } void setEmpName(string empName) { employeename = empName;
  • 5. } void setEmpDepID(string empDepId) { employeeDepartmentID = empDepId; } void setEmpAge(int empAge) { employeeage = empAge; } void setEmpSalary(double empsal) { employeesalary = empsal; } }; //Function prototypes void ShowMenu(); void choices(); int main() { ShowMenu(); choices(); return 0; } //Display Function void ShowMenu() {
  • 6. cout << "nnn"; cout << "1-Create Departmentn"; cout << "2-Creat employeen"; cout << "3-Write the data to the filen"; cout << "4-Retrive the data from the filen"; cout << "5-Display Reportn"; cout << "6-Exitn n n"; } // Choice function void choices() { // Creating array objects Department dep[3]; Employee emp[7]; string depid, empid, empdepid, depname, dephead, empname, depnamefile, depdeadfile; int empage; double empsalary; int choice; ifstream file_in, file_in2; ofstream file_out, file_out2; char again; //Used to loop the entire program int counter, empcounter, depcounter; bool id3 = false; int a; //used for getting age from file double s; //used for getting salarry from file string info; // getting lines from file size_t pos; //position double sal1, sal2, sal3; //Salaries for calculation do { cout << "Please enter a number from the menu:"; cin >> choice;
  • 7. switch (choice) { case 1: cout << "Please enter Department ID:"; cin >> depid; //Loop to not get a duplicate for (int i = 0; i < 3; i++) { while (dep[i].getDepId() == depid) { cout << "The Department ID that you entered exist. Try again:"; cin >> depid; } } //Condition to make sure not over arrays if (depcounter < 3) { cout << "Please enter the department name:"; cin >> depname; cout << "Please enter the department head:"; cin >> dephead; dep[depcounter].setDepId(depid); dep[depcounter].setDepName(depname); dep[depcounter].setDepHead(dephead); depcounter++; } else cout << "Array is full.n";
  • 8. ShowMenu(); break; case 2: cout << "Please enter the employee ID:"; cin >> empid; //Loop to not get duplicate for (int i = 0; i < 7; i++) { while (emp[i].getEmpID() == empid) { cout << "The Employee ID that you entered exist. Try again:"; cin >> empid; } } //condition to not go over arrays sizes if (empcounter < 7) { cout << "Please enter the employee department ID:"; cin >> empdepid; for (int i = 0; i < 7; i++) { if (dep[i].getDepId() == empdepid) { id3 = true; break; } } if (id3)
  • 9. { cout << "Please enter the employee Name:"; cin >> empname; cout << "Please enter the employee Age:"; cin >> empage; cout << "Please enter the employee salary:"; cin >> empsalary; emp[empcounter].setEmpID(empid); emp[empcounter].setEmpName(empname); emp[empcounter].setEmpDepID(empdepid); emp[empcounter].setEmpAge(empage); emp[empcounter].setEmpSalary(empsalary); empcounter++; } else cout << "Department not foundn"; } else cout << "Array is full.n"; ShowMenu(); break; case 3: //condition to mmake sure objects are compelted, the write to file if (depcounter == 3 && empcounter == 7) { file_out.open("dep.txt"); for (int counter = 0; counter < 3; counter++)
  • 10. { file_out << "Department ID: " << dep[counter].getDepId() << endl; file_out << "Department Name: " << dep[counter].getDepartmentName() << endl; file_out << "Department Head Name: " << dep[counter].getDepHeadName() << endl; file_out << endl << endl; } file_out.close(); file_out2.open("emp.txt"); for (int counter = 0; counter < 7; counter++) { file_out2 << "Employee ID: " << emp[counter].getEmpID() << endl; file_out2 << "Employee Name: " << emp[counter].getEmpName() << endl; file_out2 << "Employee Age: " << emp[counter].getEmpAge() << endl; file_out2 << "Employee Salary: " << emp[counter].getEmpSal() << endl; file_out2 << "Employee Department ID: " << emp[counter].getEmpDepID() << endl; file_out2 << endl << endl; } //Making sure user doesn't close the program without saving data cout << "File not saved. Do you want to save the file? (Y/N)n"; cin >> again;
  • 11. if (toupper(again) == 'Y') file_out.close(); file_out2.close(); } else cout << "Arrays not complete. Can't write into files.n" << endl << endl; ShowMenu(); break; case 4: file_in.open("dep.txt"); if (file_in) { int counter; // getting department data from file while (getline(file_in, info) && counter < 3) { pos = info.find(": "); dep[counter].setDepId(info.substr(pos + 2)); getline(file_in, info); pos = info.find(": "); dep[counter].setDepName(info.substr(pos + 2)); getline(file_in, info); pos = info.find(": "); dep[counter].setDepHead(info.substr(pos + 2)); getline(file_in, info); getline(file_in, info); counter++; }
  • 12. file_in.close(); } else cout << "File Dep not found." << endl; file_in2.open("emp.txt"); if (file_in2) { int counter; //getting employee data from file while (getline(file_in2, info) && counter < 7) { pos = info.find(": "); emp[counter].setEmpID(info.substr(pos + 2)); getline(file_in2, info); pos = info.find(": "); emp[counter].setEmpName(info.substr(pos + 2)); getline(file_in2, info); pos = info.find(": "); istringstream flow(info.substr(pos + 2)); flow >> a; emp[counter].setEmpAge(a); getline(file_in2, info); pos = info.find(": "); istringstream flow1(info.substr(pos + 2)); flow1 >> s; emp[counter].setEmpSalary(s); getline(file_in2, info); pos = info.find(": "); emp[counter].setEmpDepID(info.substr(pos + 2)); getline(file_in2, info); getline(file_in2, info);
  • 13. counter++; } file_in2.close(); } else cout << "File Emp not found." << endl; ShowMenu(); break; case 5: //Linear search through arrays for (int i = 0; i < 7; i++) { if (emp[i].getEmpDepID() == dep[0].getDepId()) { sal1 = sal1 + emp[i].getEmpSal(); } if (emp[i].getEmpDepID() == dep[1].getDepId()) { sal2 = sal2 + emp[i].getEmpSal(); } if (emp[i].getEmpDepID() == dep[2].getDepId()) { sal3 = sal3 + emp[i].getEmpSal(); } } //displaying report cout << showpoint << fixed << setprecision(2); cout << "DepartmenttSalaryreportn"; cout << dep[0].getDepartmentName() << "tt" << sal1 << "n"; cout << dep[1].getDepartmentName() << "tt" << sal2 << "n"; cout << dep[2].getDepartmentName() << "tt" << sal3 << "n";
  • 14. ShowMenu(); break; case 6: cout << "Exiting the program. Thank you." << endl; break; default: cout << "Invalid selection. Please Try again" << endl; ShowMenu(); break; } } while (choice != 6); } The purpose of this project is to take your Midterm project and implement it using Random Access Binary Files. As you recall, the Midterm project used text files to store the data. Here in the final exam project, you will be storing the data in Random Access Binary File. Also, in the Midterm project you used Arrays to temporarily hold the data in the memory until the user decides to write the data to file. Here you will not be using Arrays and instead writing the
  • 15. data directly to Random Access Binary File. Please read the chapter Advance File and I/O operations before attempting this. Here is the full description of the Final exam project. Modify your Midterm Exam Project to: 1. Replace Employee and Department classes with Employee and Department Structures. 2. Inside each structure, replace all string variables with array of characters. 3. Make Employee and Department editable. That means, the user should be able to edit a given Employee and Department. 4. Do not allow the user to edit the Employee ID and Department ID. 5. Use Random Access Files to store the data in Binary Form. This means, you should not use an Arrays to store the data in the memory. Instead, when the user wants to create a new Employee/Department, you write it to the file right away. Also when the user says he/she wants to edit an Employee/Department, ask the user to enter EmployeeID/DepartmentID. Read the data from the file and display it to the user. Allow the user to enter new data and write it back to the file in the same position inside the file. Please read the chapter . Advance File/IO operations which has examples on how to do this.