Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you fix my code the error are line 2 5 ' it ' does not name a type, line 2 7 expected primary -
Can you fix my code the error are line it does not name a type, line expected primaryexpression before token, line it was not declared in this scope, line rangebased 'for' loops are not allowed in C mode, line request for member 'firstName', 'lastName', id 'gpa' in student, which is of non class type 'const int', line it does not name a type, line expected primary expression before token, line it was not declared in this scope, line 'nullptr' was not declared in this scope, line passing 'const StudentList' as ;this' argument of 'Student StudentList::findStudentconst string& discards qualifiers fpermissive : #include
#include
#include
#include
using namespace std;
ifstream infile;
struct Student
string firstName;
string lastName;
string id;
double gpa;
;
class StudentList
list students;
public:
void addStudentconst Student &student
students.pushfrontstudent;
void deleteStudentconst string &id
line : auto it findifstudentsbegin students.end&const Student &s
line : ;
line : if it students.end
students.eraseit;
cout "Student ID: id has been deleted" endl;
else
cout "Student ID: id not found" endl;
void print const line : for const auto &student : students
line : cout student.firstName student.lastName student.id student.gpa endl;
cout endl;
Student findStudentconst string &id
line : auto it findifstudentsbegin students.end&const Student &s
return sid id;
line : ;
line : if it students.end
return ⁢
else
line : return nullptr;
void changeStudentconst string &id double newGpa
Student student findStudentid;
if student
studentgpa newGpa;
else
cout "Student ID: id not found" endl;
;
void processAddStudentList &students
Student s;
infile sfirstName slastName sid sgpa;
students.addStudents;
students.print;
void processDeleteStudentList &students
string id;
infile id;
students.deleteStudentid;
students.print;
void processSearchconst StudentList &students
string id;
infile id;
line : Student student students.findStudentid;
if student
cout "Information Located: studentfirstName studentlastName studentid studentgpa endl;
else
cout "Information for Student ID: id not found." endl;
void processChangeStudentList &students
string id;
double newGpa;
infile id newGpa;
students.changeStudentid newGpa;
students.print;
int main
char code;
StudentList students;
infile.openupdatestxt;
while infile code
switch code
case A:
case a:
processAddstudents;
break;
case D:
case d:
processDeletestudents;
break;
case S:
case s:
processSearchstudents;
break;
case C:
case c:
processChangestudents;
break;
default:
cout "Invalid code code endl;
break;
infile.close;
return ;
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