Question: Write a program read a input file and store the information in a class object below: class Person { public: Person(); /* Write any other

Write a program read a input file and store the information in a class object below: class Person { public: Person(); /* Write any other functions that are needed */ private: int presidency, birthYear, deceasedYear; string name, startDate, endDate, party; }; You program must have the following: Must include your name as part of the program output (Use the PrintMeFirst function) You must include the program outputs in a single pdf file by itself. You must separate your class object .h definition header file from your implementation file (.cpp file for the .h definition) ( See the makefile example in the winedb directory of the Ubuntu image OS on how to compile multiple files.) You must include all the source files (you can include in a zip file). However, the program output file (PDF) must be submitted as first file and then the zip file Your program must include the following: Implement all the class methods defined above Your program must read the president list text file as command line input and store the information in vector class. The command line input for the file name must use argc and argv. int main(int argc, char* argv[]) { . // sample code, your code here if (argc < 2) { cout <<"Usage: " << argv[0] << " input_file "; exit; } else fileName = argv[1]; For example, if your program name is presidentLab and the input file is presidentList.txt, then to run the program as: ./presidentLab presidentList.txt The program will open the presidentList.txt file and read all the rows and place them into vector class of Person. The presidentList.txt file has the following format: 1 ; George Washington; April 30, 1789; March 4, 1797; Independent; 1732; 1799 All the fields are separated by semicolon. The field asl follows: 1. 1 st field is the presidency term, in this example it is 1 as George Washington is our 1st president 2. 2 nd field is name of the president 3. 3 rd field is the presidency start date (stored as string) 4. 4 th field is the presidency end date (if the president is still in office, the value is 0) 5. 5 th field is presidents polical party 6. 6 th field is presidents birth year 7. 7 th field is presidents deceased year. If the president is still alive, the value will be 0. Your goal is 1st read the file and separate all the individual field separated by semicolon, and store each row as a class object, and store in vector. Sample files: 1; George Washington; April 30, 1789 ; March 4, 1797 ; Independent; 1732; 1799 2; John Adams; March 4, 1797 ; March 4, 1801 ; Federalist; 1735; 1826 44; Barack Obama; January 20, 2009 ; January 20, 2017 ; Democratic; 1961; 0 45; Donald Trump; January 20, 2017 ; 0; Republican; 1946; 0 /* Sample code to open files Your program may be different. The goal is to read file and store each record (line) into a class object vector */ ifstream myfile (fileName.c_str()); // open the file if (myfile.is_open()) { while (myfile) { if (!getline(myfile, str)) break; //end of file istringstream split(str); // use istringstream function to work on the line vector tokens; // use to store each field for the line while (split) // parse the line, place all the field for each line // temporaryly into a vector { string s; if (!getline()) // hint use getline delimiter option break; // end of line else // get the field that is separated by the delimiter { /* implment function trim_words to get rid of leading and training exmpty spaces look at my sample code how to get rid of leading/trailing spaces */ str1 = trim_words(s); tokens.push_back(str1); // add each individual field for this line // into tokens vector so you can use once your finish //process this line } } // now use `tokens` /* loop through the tokens vector where you stored all the individual fields for this line and then assign them to your class objects and store them into your class object vector */ } After you successfully read the file, your program will print out users menu as follow: Your program will have an users menu similar to the one below: 1. Search persons information based on name (enter persons name and will print out the information for all the records that matches persons name). HINT: use string find function. For example, if person enters Adam, it will return information for John Adam and John Quincy Adams. If a person enters Bush, it will print out information for George H. W. Bush and George W. Bush. 2. Search persons information based on Presidency term. For example, if your input is 44, then it will print out our 44th president. Check fo validity of inputs, for example, all inputs must be positive number. 3. Search persons information based on polical party (enter polical party name and will print out the information for all the records that matches persons polical party) 4. Exit if user enters Exit or Quit or 4, the program will exit. When priting out presidents information, your output must use the format below. Use the test case below for your program input, for example, for option 1 (search persons information based on name), if your input is Regan then the output is : Ronald Reagan (1911 2004) Age: 93 Presidency #40 from January 20, 1981 to January 20, 1989 Party: Rebulican If input is Obama, the output is: Barack Obama (1961 Present) Age: 56 Presidency #44 from January 20, 2009 to January 20, 2017 Party: Democratic If input is Adam, the output is: John Adams (1735 1826) Age: 91 Presidency #2 from March 4, 1797 to March 4, 1801 Party: Federalist John Quincy Adams (1767 1848) Age: 81 Presidency #6 from March 4, 1825 to March 4, 1829 Party: Democratic For Option 2, search president information based on presidency term. Use the test case below: If input is -10, your program will reject this output and ask user to reenter a positive number. If the input is 40, your program will print out: Ronald Reagan (1911 2004) Age: 93 Presidency #40 from January 20, 1981 to January 20, 1989 Party: Rebulican If the input is 44, your program will print out: Barack Obama (1961 Present) Age: 56 Presidency #44 from January 20, 2009 to January 20, 2017 Party: Democratic PDF file output must have: Program Description/Purpose: - Describe what is the purpose of the program, how does it work. Program Inputs: - Describe what inputs are required for this program Program Outputs: - Describe the output of the program Source Code: - Include the source code here Program Output: - Inlucde screen shots of your program outputs And also i want my program to print #include using namespace std; /** Function header file MUST be included for all your functions Print out the programmers information such as name, class information and date/time when the program is run @param name - the name of the programmer @param courseInfo - the name of the course @return - none */ void printMeFirst(string name, string courseInfo) { You must include the printMeFirst() function as 1st line of your program. You need to pass your name, your class info to function so it will print them out. Always call this function in all of your lab program for this class. */ printMeFirst("YourFirstName YourLastName", "Lab1: CS116-01") And my name is I Singh Lab3 CS116-01

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!