Q1) Filtering Files Assume the information of all the TAs for the ECE department is stored in a file that is called TAs.txt. In order to be eligible for the TA position, a student should be currently registered (i.e. not be an alumni). However, the file contains old data; it includes some records of TAs who have already graduated and who are no longer allowed to TA. The format of each TA record in the file is as follows: Status . Grad The first line of the file should show the total number of students records (max number of records is 100, you don't need to check for going over). Note that the TAs can be classified as any of the following (even if they don't all appear in your example): . UGrad • Alum After Correction: Part A) You need to write a program that reads the file, removes any lines with invalid TAs (those who have Alum as the value for classification) and updates the original file in the same format, just having removed invalid TAS. Work with a vector of TA objects. Example 1 Initial Student File: 6 Grad Shawn 3927320 MIAE 6 Alum Nick 4386508 CSSE 7 Alum John 96320753 ECE 10 Alum Kate 52935193 MIAE 8 Alum Younes 0263193 MIAE 5 Alum Charles 0827261 BCEE 11 1 Grad Shawn 3927320 MIAE 6. Part B) First Name Implement a function addNewTA () that prompts the user for the information representing one TA. When a user selects 1, ask the user to enter new TAs: TA information should be entered in the same order as the fields are stored in the file: Status First Name Student Id Dept Working Hours Student Id Dept Please enter TA information separated by tabs to avoid confusion when parsing. Adding a TA in this should add the TA into the existing file. However, if a user enters a TA with a Student Id that is already in the file, the program should reject the input and keep looping until a new Student Id is entered (but not entering the other data, that should be remembered). 7 int main() { 8 std::string input; 9 10 11 12 Your program should handle any exceptions (or other problems) if the user tries to enter information of an unexpected type, like a string for the Student_Id. Here is an example of how to handle an exception in C++: 13 14 15 16 Working Hours 17 18 19 std::cout << "Enter an integer: "; try { } std::getline (std::cin, input); int number = std::stoi (input); std::cout << "You entered << number << std::endl; } catch (const std::invalid_argument& e) { std::cerr << "Error: " << e. what () << " is not a valid integer.\n"; } catch (const std::out_of_range& e) { std::cerr << "Error: " << e. what () << " is out of range.\n"; Figure 1: Handling an exception in C++ Note: This menu should be offered after the original behavior from Part A is complete. When the user
Q1) Filtering Files Assume the information of all the TAs for the ECE department is stored in a file that is called TAs.txt. In order to be eligible for the TA position, a student should be currently registered (i.e. not be an alumni). However, the file contains old data; it includes some records of TAs who have already graduated and who are no longer allowed to TA. The format of each TA record in the file is as follows: Status . Grad The first line of the file should show the total number of students records (max number of records is 100, you don't need to check for going over). Note that the TAs can be classified as any of the following (even if they don't all appear in your example): . UGrad • Alum After Correction: Part A) You need to write a program that reads the file, removes any lines with invalid TAs (those who have Alum as the value for classification) and updates the original file in the same format, just having removed invalid TAS. Work with a vector of TA objects. Example 1 Initial Student File: 6 Grad Shawn 3927320 MIAE 6 Alum Nick 4386508 CSSE 7 Alum John 96320753 ECE 10 Alum Kate 52935193 MIAE 8 Alum Younes 0263193 MIAE 5 Alum Charles 0827261 BCEE 11 1 Grad Shawn 3927320 MIAE 6. Part B) First Name Implement a function addNewTA () that prompts the user for the information representing one TA. When a user selects 1, ask the user to enter new TAs: TA information should be entered in the same order as the fields are stored in the file: Status First Name Student Id Dept Working Hours Student Id Dept Please enter TA information separated by tabs to avoid confusion when parsing. Adding a TA in this should add the TA into the existing file. However, if a user enters a TA with a Student Id that is already in the file, the program should reject the input and keep looping until a new Student Id is entered (but not entering the other data, that should be remembered). 7 int main() { 8 std::string input; 9 10 11 12 Your program should handle any exceptions (or other problems) if the user tries to enter information of an unexpected type, like a string for the Student_Id. Here is an example of how to handle an exception in C++: 13 14 15 16 Working Hours 17 18 19 std::cout << "Enter an integer: "; try { } std::getline (std::cin, input); int number = std::stoi (input); std::cout << "You entered << number << std::endl; } catch (const std::invalid_argument& e) { std::cerr << "Error: " << e. what () << " is not a valid integer.\n"; } catch (const std::out_of_range& e) { std::cerr << "Error: " << e. what () << " is out of range.\n"; Figure 1: Handling an exception in C++ Note: This menu should be offered after the original behavior from Part A is complete. When the user
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 1GZ
Related questions
Question
do this in C++. complete all the parts and follow every instructions. explain all the steps and where and why did you use that.
please do not copy or plagarise from other sources, ignore if you can't answer it.
give the written code & SHOW screenshots of code+ outputs
Thank you in advance for your time and help.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,