Question: In C++ complete the following with an implementation file header file and source file. You are asked to write a program that reads this input

In C++ complete the following with an implementation file header file and source file.

You are asked to write a program that reads this input file and separate faculty from students then prints the output of each category to a separate output file. To keep track with each faculty member and each student we need to create an object for each one. To avoid repeating variables and functions, we will create a general class and call it Members. This class contains the shared data that each student and faculty member should have (first name, last name, id). Our class should also have the following:

A constructor that takes no arguments.

A constructor that takes three arguments to set the member variable: first name, last name, and id. Members(const string& firstName, const string& lastName, int idNum);

A print function printMember that prints first name, last name, and the id for the calling object. void printMember() const;

A function readWriteMembers that accepts an input file object and output file object to read and write members to files. (The definition in the Base class is not that important since we will use it to read student members or faculty members only). void readWriteMembers(ifstream& instream, ofstream& outstream);

Getters and setters for the first name, last name, and id.

We will have two derived classes, the first one called Faculty. This class inherits all member variables and member functions from Members. It also has the following:

An extra member variable called salary of type double

A constructor with no arguments.

In the parameterized constructor, call the base class constructor to set the first name, last name, and id. Then set the salary member variable. Redefine the function printMember to print the data for the calling object such as The faculty member name is , the id is , and the salary is .

Redefine the function readWriteMembers to read the input file (the lines that start with f only). Then send the following output to an output file called FacultyOutput.txt: Faculty name: ID: Salary: .

Getters and setters for the salary.

The second class is Student that inherits all member variables and member functions from Members and has the following details:

An extra member variable major of type string.

A constructor that takes no arguments.

A constructor that accepts four arguments. Call the base class constructor to set the first three arguments, then set the major member variable.

Redefine the member function printMember to print the calling object data such as The student name is ID: . Major:... Redefine the member function readWriteMembers to read the input file (the lines that start with s only). Then send the following output to an output file called StudentOutput.txt: Student name: ID: Major: .

Getters and setters for the major.

In the main, you should only create the file input and output objects, Faculty object, and a Student object. Then call the readWriteMembers for each class instance and let the redefined member function take care of the rest. The getters and setters are really important, since you may want to create and add a new Student to the output by typing the following: Student stu (Max, underwoo, 703, Science); Note: in the previous line we made a mistake and we entered a wrong name. In this case you can simply fix it as the following: Stu.setLastName(Underwood); Then you may print this student information or another student information as the following: Stu.printMember(); //This is the difference between this function and readWriteMembers

input file:

f Zach Shiffer 100 10000.29 s Jack Smith 102 Art f Toni Alberto 103 98000.39 s Sam Wael 104 History s Kim Watson 105 Math s Nancy Thomson 106 Geography s Tim Jefferson 107 Art f Andrew Jazz 108 94000.55 f Kyle Zipp 109 68344.09 s Sam Anthony 110 Engineering 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!