Answered step by step
Verified Expert Solution
Question
1 Approved Answer
// The purpose of the program is to store student record information // search the student record by using student_id and lastly, // display all
// The purpose of the program is to store student record information // search the student record by using student_id and lastly, // display all the records in a menu based system #include#include #include #include using namespace std; // menu choices const string EXIT = "4", ADD_NEW = "1", SEARCH = "2", VIEW_ALL = "3"; // student structure struct Student { unsigned id; // positive value string name; // name with space allowed }; // this function will input values for a new movie record // and will return that void add_new_record(Student & newStudent) { cout< >newStudent.id; cin.ignore(); // ignores the newline character cout<<"Student Name: "; getline(cin, newStudent.name); } // creating a single string value out of // all the fields of the movie struct string to_string(const Student & student_rec) { string result = "create the string from a student record"; return result; } // search the student records based on title void find_student_record(unsigned search_id, const vector & student_records) { bool found_flag = false; // TODO - SEARCHING the vector // loop through all the elements of the student record // check whether the ID of the student matches with the search_id // if yes, change the found_flag to be true and display the record // if a record is found found_flag becomes true if(found_flag==false) { cout< & student_records) { cout< student_records; // holds all student records do { choice = display_menu(); if(choice==ADD_NEW) // add new record { // TODO - adding new struct elements in the vector variable // Declare a variable of Student struct type // call the add_new_record function; use the struct variable as the parameter // add the struct variable to the student_records vector } else if(choice==SEARCH) // search based on title { int search_id; // get the ID to search from the user cout< >search_id; cin.ignore(); // consume the new line character // call the search function and supply it with the search id find_student_record(search_id, student_records); } else if(choice == VIEW_ALL) // view all records { // call the function view_all_records to display all student records view_all_records(student_records); } } while (choice!=EXIT); // exit condition cout<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started