Question: PLEASE IN C + + THIS IS DUE TODAY ( I need the code not an explanation ) Given a program that searches for a
PLEASE IN C THIS IS DUE TODAY I need the code not an explanation
Given a program that searches for a students ID or name in a text file, complete the FindID and FindName functions. Then, insert a trycatch statement in main to catch any exceptions thrown by FindID or FindName and output the exception message. Each line in the text file contains a name and ID separated by a space.
Function FindID has two parameters: a student's name string and the text file's contents ifstream The function FindID returns the ID associated with the student's name if the name is in the file, otherwise the function throws a runtimeerror with the message "Student ID not found for studentName", where studentName is the name of the student.
Function FindName has two parameters: a student's ID string and the text file's contents ifstream The function FindName returns the name associated with the student's ID if the ID is in the file, otherwise the function throws a runtimeerror with the message "Student name not found for studentID", where studentID is the ID of the student.
The main program takes three inputs from a user: the name of a text file string the search option for finding the ID or name of a student int and the ID or name of a student string If the search option is FindID is invoked with the student's name as an argument. If the search option is FindName is invoked with the student's ID as an argument. The main program outputs the search result or the caught exception message.
Ex: If the input of the program is:
roster.txt Reagan
and the contents of roster.txt are:
Reagan rebradshaw Ryley rbarber Peyton pstott Tyrese tmayo Caius ccharlton
the output of the program is:
rebradshaw
Ex: If the input of the program is:
roster.txt Mcauley
the program outputs an exception message:
Student ID not found for Mcauley
Ex: If the input of the program is:
roster.txt rebradshaw
the output of the program is:
Reagan
Ex: If the input of the program is:
roster.txt mpreston
the program outputs an exception message:
Student name not found for mpreston
I have gotten the first part but can not get student name not found
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
