I need a little help with writing the output for this Code i

I need a little help with writing the output for this. Code is beneath it in C++. Help ASAP. Output goes at very bottom.

\"Output consists of updated values for the three “past history” information numbers describing each student. These updated values must merge the information from the student’s past history with the grades she earned this semester.

In addition, you must compute the student’s GPA for the current semester and overall GPA for all semesters. The GPA is defined as the grade points earned divided by the number of graded credits attempted. If the student has no attempted graded credits (for the semester or overall), report a GPA of 0.0.\"

=======================

====================

Solution

Here is the complete code. I merged the header file in same file. I hope the formula I used is correct.

#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>


/**
* Driver for the GPA program.
* Input is read from standard in and consists of student grade info.
* This info begins with one line containing the student\'s credits earned,
* graded credits attempted, and gradePoints so far.
* This is followed by some number of lines (terminated by end of input)
* each containing a grade code earned in some course this semester,
* one or more blanks, then the number of credits for which the student
* took that course.
*
* Output is written to standard out.
*
*/

using namespace std;

double get_points_from_grade(const std::vector<std::string>& gradeCodes,   
const std::vector<double>& pointValues, string grade){
// returns the corrospoding point of a grade for calculation
for (int i = 0; i < gradeCodes.size(); ++i)
{
if(gradeCodes[i] == grade ) return pointValues[i];
}

return -1.0;
}

bool get_affectsCreditsEarned_from_grade(const std::vector<std::string>& gradeCodes,   
const std::vector<bool>& affectsCreditsEarned, string grade){

// returns whether a grade effects credit earned or not
for (int i = 0; i < gradeCodes.size(); ++i)
{
if(gradeCodes[i] == grade ) return affectsCreditsEarned[i];
}

return -1.0;
}
void computeGPA (/* University Info */
const std::vector<std::string>& gradeCodes,
const std::vector<bool>& affectsGPA,
const std::vector<bool>& affectsCreditsEarned,
const std::vector<double>& pointValues,

/* student history info */
int creditsEarned,
int gradedCreditsAttempted,
double gradePoints,

/* student semester grades */
const std::vector<std::string>& gradeReported,
const std::vector<int>& creditsRegisteredFor,

/* outputs */
int& updatedCreditsEarned,
int& updatedGradedCreditsAttempted,
double& updatedGradePoints,
double& semesterGPA,
double& overallGPA)
{

  
// reset the output values
updatedGradePoints = 0;
updatedCreditsEarned = 0 ;
updatedGradedCreditsAttempted = 0;
semesterGPA = 0.0;
overallGPA = 0.0;
  
for (int i = 0; i < gradeReported.size(); ++i)
{
  
  
updatedGradedCreditsAttempted += creditsRegisteredFor[i];
if(get_affectsCreditsEarned_from_grade(gradeCodes, affectsCreditsEarned, gradeReported[i]) == true){
updatedCreditsEarned += creditsRegisteredFor[i];
}

updatedGradePoints += get_points_from_grade(gradeCodes, pointValues, gradeReported[i])*creditsRegisteredFor[i];
  

  

}

semesterGPA = updatedGradePoints/updatedGradedCreditsAttempted;

overallGPA = (gradePoints + updatedGradePoints)/(gradedCreditsAttempted + updatedGradedCreditsAttempted);


}

void addGradeEntry (vector<std::string>& gradeCodes,
vector<bool>& affectsGPA,
vector<bool>& affectsCreditsEarned,
vector<double>& pointValues,
string gradeCode, bool affGPA,
bool affCredits, double pointVal)
{
gradeCodes.push_back (gradeCode);
affectsGPA.push_back (affGPA);
affectsCreditsEarned.push_back (affCredits);
pointValues.push_back (pointVal);
}

void initializeGradingScheme (vector<std::string>& gradeCodes,
vector<bool>& affectsGPA,
vector<bool>& affectsCreditsEarned,
vector<double>& pointValues)
{
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"A\", true, true, 4.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"A-\", true, true, 3.7);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"B+\", true, true, 3.3);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"B\", true, true, 3.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"B-\", true, true, 2.7);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"C+\", true, true, 2.3);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"C\", true, true, 2.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"C-\", true, true, 1.7);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"D+\", true, true, 1.3);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"D\", true, true, 1.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"D-\", true, true, 0.7);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"F\", true, false, 0.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"P\", false, true, 0.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"F*\", false, false, 0.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"I\", false, false, 0.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"W\", false, false, 0.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"WF\", true, false, 0.0);
addGradeEntry (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
\"Z\", false, false, 0.0);
}

void readSemesterGrades (istream& in,
vector<string>& gradeReported,
vector<int>& creditsRegisteredFor)
{
string line;
getline (in, line);
while (!!in)
{
istringstream lineReader (line);
string gradeCode;
int credits;
lineReader >> gradeCode >> credits;
gradeReported.push_back (gradeCode);
creditsRegisteredFor.push_back (credits);
getline (in, line);
}
}


void studentGradeSummary (istream& in)
{
vector<std::string> gradeCodes;
vector<bool> affectsGPA;
vector<bool> affectsCreditsEarned;
vector<double> pointValues;

initializeGradingScheme(gradeCodes, affectsGPA,
affectsCreditsEarned, pointValues);


int creditsEarned;
int gradedCreditsAttempted;
double gradePoints;
in >> creditsEarned >> gradedCreditsAttempted >> gradePoints;
string garbage;
getline (in, garbage);

vector<std::string> gradeReported;
vector<int> creditsRegisteredFor;
readSemesterGrades (in, gradeReported, creditsRegisteredFor);

int newCreditsEarned = -1;
int newGradedCreditsAttempted = -1;
double newGradePoints = -1.0;
double semesterGPA = -1.0;
double overallGPA = -1.0;

computeGPA (gradeCodes, affectsGPA, affectsCreditsEarned, pointValues,
creditsEarned, gradedCreditsAttempted, gradePoints,
gradeReported, creditsRegisteredFor,
newCreditsEarned, newGradedCreditsAttempted, newGradePoints,
semesterGPA, overallGPA);

cout << \"Credits earned:\\t\" << newCreditsEarned
<< \"\ Attempted:\\t\" << newGradedCreditsAttempted
<< \"\ Grade Points:\\t\"
<< setiosflags(ios::fixed) << setprecision(2) << newGradePoints
<< endl;

cout << \"Semester GPA:\\t\"
<< setiosflags(ios::fixed) << setprecision(2) << semesterGPA
<< endl;

cout << \"Overall GPA:\\t\"
<< setiosflags(ios::fixed) << setprecision(2) << overallGPA
<< endl;

}


int main (int argc, char** argv)
{
studentGradeSummary (cin);

return 0;
}

input

0 0 0
A 4
B 3
C 2
D 2
Z 5

OUTPUT

Credits earned:   11
Attempted:   16
Grade Points:   31.00
Semester GPA:   1.94
Overall GPA:   1.94

I need a little help with writing the output for this. Code is beneath it in C++. Help ASAP. Output goes at very bottom. \
I need a little help with writing the output for this. Code is beneath it in C++. Help ASAP. Output goes at very bottom. \
I need a little help with writing the output for this. Code is beneath it in C++. Help ASAP. Output goes at very bottom. \
I need a little help with writing the output for this. Code is beneath it in C++. Help ASAP. Output goes at very bottom. \
I need a little help with writing the output for this. Code is beneath it in C++. Help ASAP. Output goes at very bottom. \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site