Question: Create a program that can read from a file called student.csv which has multiple students with multiple classes (see image) and prints the student name

Create a program that can read from a file called student.csv which has multiple students with multiple classes (see image) and prints the student name and their weighted/ unwighted GPA using C++ language.

It is preferred to use the class method rather than a struct. once it reads ENDOFSTUDENTRECORD it should start a new student.

I would appreciate any help possible

Create a program that can read from a file called student.csv which

this is the cod i have so far

#include

#include

#include

#include

#include

#include

using namespace std;

class Course //should come first to be visible for other classes

{

public:

string title;

string grade;

string type;

double credits;

//Default Constructor

Course()

{

title ="";

grade ="";

type="";

credits=0;

}

//Constructor

Course(string titleInput, string gradeInput, string typeInput, double creditsInput)

{

title = titleInput;

grade = gradeInput;

type = typeInput;

credits = creditsInput;

}

};

class Student

{

public:

string name;

vector courses;

double creditsCompleted;

double pointsTotal;

double GPA;

Student()

{

name="";

}

Student(string nameInput)

{

name = nameInput;

creditsCompleted=0;

pointsTotal=0;

}

double calculateGPA()

{

GPA=pointsTotal/creditsCompleted;

return GPA;

}

void addCourse(Course c)

{

courses.push_back(c);

creditsCompleted+=c.credits;

if(c.grade == " A")

{

pointsTotal+=4;

}

else if(c.grade == " B")

{

pointsTotal+=3;

}

else if(c.grade == " C")

{

pointsTotal+=2;

}

else if(c.grade == " D")

{

pointsTotal+=1;

}

//Anything else will not add to pointsTotal

}

};

int main() {

ifstream myFile("student.csv");

vector students; //empty vector containing students

Student temp;

string line;

string name;

double sumOfPoints;

int sumOfCredits;

string flag = "ENDOFSTUDENTRECORD"; //set default

if( myFile.is_open())

{

while (getline(myFile,line))

{

stringstream ss(line);

string value;

while(getline(ss, value,','))

{

//check to see if ENDOFSTUDENTRECORD is applicable and if so. Push the student record - temp - to the students list.

//if it is not the ENDOFSTUDENTRECORD, you would add the course to the students list of courses.

//temp.addCourse(input a new course)

/ew Course(string titleInput, string typeInput, double creditsInput, string gradeInput)

}

}

//make a loop to print out all of the students' GPAs

for(int i = 0; i

{

cout

}

}

}

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Dwayn "The Rock" Johnson Drifting 101, Advanced Placement, 1, A English 112, Regular, 1, B Smoldering Looks, Honors, 1, A Acting, Advanced Placement, 1, A Health & PE 9, Honors, 1, A Digital Applications, Regular, 1, B Time Travel Preparedness, Regular, 1, A Video Gaming, Regular, 1, F Zombie Survival, Honors, 1, B ENDOFSTUDENTRECORD Calculator Johnson Algebra II Honors, Honors, 1, A English 9 Honors, Honors, 1, A Biology Honors, Honors, 1, B AP Human Geography, Advanced Placement, 1, A Health & PE 9, Regular, 1, A Dual Enrollment Calculus, Advanced Placement, 2, A ENDOFSTUDENTRECORD 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Dwayn "The Rock" Johnson Drifting 101, Advanced Placement, 1, A English 112, Regular, 1, B Smoldering Looks, Honors, 1, A Acting, Advanced Placement, 1, A Health & PE 9, Honors, 1, A Digital Applications, Regular, 1, B Time Travel Preparedness, Regular, 1, A Video Gaming, Regular, 1, F Zombie Survival, Honors, 1, B ENDOFSTUDENTRECORD Calculator Johnson Algebra II Honors, Honors, 1, A English 9 Honors, Honors, 1, A Biology Honors, Honors, 1, B AP Human Geography, Advanced Placement, 1, A Health & PE 9, Regular, 1, A Dual Enrollment Calculus, Advanced Placement, 2, A ENDOFSTUDENTRECORD 16 17 18 19

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!