Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could someone help me with this? I just need to fill in the \"insert\" part and

ID: 645541 • Letter: C

Question

Could someone help me with this? I just need to fill in the "insert" part and it should be quick to do!

You have been given a Student class. A user will insert a name followed by a double representing a GPA. The user will enter these in pairs followed by the word "STOP" With each name and GPA,create a Student pointer and insert it into the "students" vector. You must print all the GPAs in the vector in reverse order. Example: Input: Iris 4.5 Kevin 10.8 Gretchen 2.1 STOP Output: 2.1 10.8 4.5

#pragma once
#include
#include
#include

using namespace std;

class Student
{
private:
   string name;
   double gpa;

public:
   Student(string name, double newGPA);
   string getName();
   void setName(string newName);
   double getGPA();


   ~Student();
};

Student::Student(string studentName, double newGPA)
{
   name = studentName;
   gpa = newGPA;
}

string Student::getName()
{
   return name;
}

void Student::setName(string newName)
{
   name = newName;
}

double Student::getGPA()
{
   return gpa;
}

Student::~Student()
{
}

//
// You may insert a function here

int main()
{
   vector students;
  

   return 0;
}

Explanation / Answer

Answer:

#include<iostream>

#include<string>

#include<vector>

#include<conio.h>

using namespace std;

class Student

{

private:

        string name;

   double gpa;

public:

          Student();

Student(string name, double newGPA);

          string getName();

void setName(string newName);

double getGPA();

void setGPA(double newGpa);

~Student();

};

Student::Student()

{}

Student::Student(string studentName, double newGPA)

{

   name = studentName;

   gpa = newGPA;

}

string Student::getName()

{

   return name;

}

void Student::setName(string newName)

{

   name = newName;

}

double Student::getGPA()

{

   return gpa;

}

void Student::setGPA(double newGpa)

{

   gpa=newGpa;

}

Student::~Student()

{}

int main()

{

vector<Student> stud;

string stname;

Student *sptr;

double CGPA;

do

{

sptr=new Student;

cout<< "Enter the name and CGPA value (Uset STOP to stop the input)";

        cin >> stname;

        cin >> CGPA;

        sptr->setName(stname);

        sptr->setGPA(CGPA);

        stud.push_back(*sptr);

  

}while(stname!="stop");

vector<Student> ::iterator itr;

for(itr=stud.begin();itr!=stud.end();itr++)

{

cout<<itr->getGPA()<<" ";

}

getch();

return 0;

}