CODE C++ PLEASE #include <iostream> #include <string> #include <vector> #include
ID: 3938432 • Letter: C
Question
CODE C++ PLEASE
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;
class Student {
public:
Student(string name = "not intialized", double GPA = 0.0);
void SetName(string studentName);
void SetGPA(double personName);
string ToString() const;
private:
string name;
double GPA;
};
Student::Student(string initialName, double initialGPA) {
name = initialName;
GPA = initialGPA;
}
void Student::SetName(string inputName) {
name = inputName;
}
void Student::SetGPA(double newGPA) {
GPA = newGPA;
}
//Insert the ToString member function here
int main() {
vector<Student*> students;
//Insert your code for main here
return 0;
}
Explanation / Answer
Please find the code for main function:
int main() {
vector<Student*> students;
int i =0;
string opt;
char ch;
do
{
cout<<"Enter Option ";
cin>>opt;
switch (opt)
{
case add: students.push_back(Setname(i));
students.push_back(SetGPA(i));
i++;
break;
case print: students(Tostring());
break;
case drop: students.erase(students.begin()+i);
i--;
break;
}
cout<<"want to terminate, enter y";
cin>>y;
}while(ch=='y' !! ch=='Y');
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.