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

C++ Programming Question using Visual Studio. Complete implementations for the s

ID: 3875699 • Letter: C

Question

C++ Programming Question using Visual Studio.

Complete implementations for the student member functions given the structure below in order to compute the GPAs for two students. The credit and grade data member arrays hold the number of credits for each course taken and its corresponding letter grade, respectively. The data member numCourses indicates how many of the 100 array elements contain valid data, i.e. the number of courses the student has completed.

1. Complete implementations for the student member functions given the structure below in order to compute the GPAs for two students. The credit and grade data member arrays hold the number of credits for each course taken and its corresponding letter grade, respectively. The data member numCourses indicates how many of the 100 array elements contain valid data, i.e. the number of courses the student has completed. The member function setGrades is passed arrays of length numIn containing the number of credits and letter grades for each of the numIn courses. The function should store this information in the data members. The member function addGrade is passed a single course, with its corresponding number of credits and letter grade, to be appended to whatever information is already stored in the data members. The member function getGPA will loop through all the course information stored in the data members and return the student's current GPA #include using namespace std; struct student int credit [100], numCourses; char grade [100]; void setGrades (int creditIn], char gradeIn], int numIn); void addGrade (int creditIn , char gradeIn double getGPA); int main() const int numStart = 5; int startCredit [nunStart]= { 3, 4, 3, 2, 4 }; char startGrade [nunStart] = { ·A', A',"B', 'C', 'B' }; me .setGrades (startCredit, startGrade, numStart); you.setGrades (startCredit, startGrade, numStart); me·addGrade(4,·C' ); me .addGrade(3, 'F); you.addGrade (2, Byou.addGrade (4, 'A); cout

Explanation / Answer

Given below is the completed code for the question.
Please do rate the answer if it was helpful. Thank you


#include <iostream>
using namespace std;
struct student{
int credit[100], numCourses;
char grade[100];
void setGrades(int creditIn[], char gradeIn[], int numIn)
{
  
for(int i = 0; i < numIn; i++)
{
credit[i] = creditIn[i];
grade[i] = gradeIn[i];
}
numCourses = numIn;
}
void addGrade(int creditIn, char gradeIn)
{
credit[numCourses] = creditIn;
grade[numCourses] = gradeIn;
numCourses++;
}
double getGPA()
{
double gpa = 0, total = 0;
for(int i = 0 ; i < numCourses; i++)
{
total += credit[i];
if(grade[i] == 'A')
gpa += credit[i] * 4;
else if(grade[i] == 'B')
gpa += credit[i] * 3;
else if(grade[i] == 'C')
gpa += credit[i] * 2;
else if(grade[i] == 'D')
gpa += credit[i] * 1;
  
}
gpa /= total;
return gpa;
}
};

int main(){
const int numStart = 5;
int startCredit[numStart] = {3, 4, 3, 2, 4};
char startGrade[numStart] = {'A', 'A', 'B', 'C', 'B'};
student me, you;
me.setGrades(startCredit, startGrade, numStart);
you.setGrades(startCredit, startGrade, numStart);
me.addGrade(4, 'C'); me.addGrade(3, 'F');
you.addGrade(2, 'B'); you.addGrade(4, 'A');
  
cout << " I have a " << me.getGPA() << " GPA " << endl;
cout << "You have a " << you.getGPA() << " GPA" << endl;
return 0;
}

output
=====
I have a 2.65217 GPA
You have a 3.40909 GPA

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote