Answered step by step
Verified Expert Solution
Question
1 Approved Answer
change this code to stl: #include #include #include #include using namespace std; ifstream infile; struct studentNode { string firstName; string lastName; string id; double gpa;
change this code to stl: #include
#include
#include
#include
using namespace std;
ifstream infile;
struct studentNode
string firstName;
string lastName;
string id;
double gpa;
studentNode next;
;
class studentList
studentNode students;
public:
void addStudentstudentNode;
void deleteStudentstudentNode studentNode;
void locateStudentstring id bool &end, studentNode &curr, studentNode &prev;
void changeStudentstring bool, double, studentNode curr;
void print;
;
void studentList::addStudentstudentNode studentRec
studentNode temp new studentNode;
temp studentRec;
tempnext students;
students temp;
void studentList::deleteStudentstudentNode curr studentNode prev
if prev NULL
students students next;
else if curr NULL
prev next NULL;
else
prev next curr next;
void studentList::locateStudentstring id bool &end, studentNode &curr, studentNode &prev
for studentNode s students; s NULL && end false; s s next
if s id id
end true;
curr s;
else
prev s;
void studentList::changeStudentstring id bool end, double gpa, studentNode curr
if end true
curr gpa gpa;
else if end false
curr NULL;
cout Student ID id not found" endl;
void studentList :: print
forstudentNode s students; s NULL; s snext
cout sfirstName slastName sid sgpa endl;
cout endl;
void processAddstudentList &students
studentNode s;
infile sfirstName;
infile slastName;
infile sid;
infile sgpa;
students.addStudents;
void processDeletestudentList &students
bool end false;
string id;
studentNode curr NULL;
studentNode prev NULL;
infile id;
students.locateStudentid end curr prev;
if end true
students.deleteStudentcurrprev;
cout "Student ID: id has been deleted" endl;
else if end false
cout "Student cannot be found." endl;
cout endl;
void processSearchstudentList &students
bool end false;
string id;
studentNode curr NULL;
studentNode prev NULL;
infile id;
students.locateStudentidend,curr,prev;
if end true
cout "Information Located: curr firstName curr lastName currid curr gpa endl;
else
cout "Information: id cannot be found.";
void processChangestudentList &students
bool end false;
string id;
double gpa;
studentNode curr NULL;
studentNode prev NULL;
infile id;
students.locateStudentidend,curr,prev;
int main
char code;
studentList students;
infile.openupdatestxt;
while infile.eof
infile code;
if code A code a
processAddstudents;
students.print;
else if code D code d
processDeletestudents;
students.print;
else if code S code s
processSearchstudents;
else if code C code c
processChangestudents;
students.print;
else
cout "Invalid code code
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