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

Answer this question using c++. Here is my code from the program 2 mentioned in

ID: 3746035 • Letter: A

Question

Answer this question using c++. Here is my code from the program 2 mentioned in the question.

#include <iostream>
#include <string>
using namespace std;

class Student {
public:
string student_name;
string lettergrade;
float exam_1grade;
float exam_2grade;
float GPA;
void getGrade();
private:
void calcGPA();
};

void setStudentName(Student& c, string name)
{
c.student_name = name;
}
void setGrade1(Student& c, float grade1)
{
c.exam_1grade = grade1;
}
void setGrade2(Student& c, float grade2)
{
c.exam_2grade = grade2;
}
void calcGPA(Student& c)
{
c.GPA = (c.exam_1grade + c.exam_2grade) / 2;
}
void getGrade(Student &c)
{
if (c.GPA <= 100 && c.GPA >= 90)
c.lettergrade = "A";
else if (c.GPA < 90 && c.GPA >= 80)
c.lettergrade = "B";
else if (c.GPA < 80 && c.GPA >= 70)
c.lettergrade = "C";
else if (c.GPA < 70 && c.GPA >= 60)
c.lettergrade = "D";
else if (c.GPA < 60 && c.GPA >= 0)
c.lettergrade = "F";
}
void output(Student& c)
{
cout << "Student: " << c.student_name << endl;
cout << "First Exam Grade: " << c.exam_1grade << endl;
cout << "Second Exam Grade: " << c.exam_2grade << endl;
cout << "Grade: " << c.lettergrade << endl;
cout << "--------------------------" << endl;
}
int main(){
Student c;
setStudentName(c,"Amy");
setGrade1(c,95);
setGrade2(c,90);
calcGPA(c);
getGrade(c);
output(c);
return 0;
}

Augment the Student class. Copy program 2 to a new program. a. Outside of the class, create a partially filled array of type Student b. Outside of the class, create an addStudent function that: named students of capacity 10 1. Creates a new student with data populated by input parameters. 2. Adds the new student to the students array c. Outside of the class, create an output ) function that: 1. Outputs all student data in the students array as displayed in the output example (see next page) d. Create a final driver program that creates five students and outputs their data as shown in the output example ET-580 Object-Oriented Programming S. Trowbridge 2018 Output Example Name: Amy Exam 1: 95 Exam 2: 90 GPA: A Name: Bob Exam 1 74 Exam 2: 63 GPA: D Name: Charlie Exam 1: 86 Exam 2: 80 GPA: B Name: Daisy Exam 1: 75 Exam 2: 99 GPA: B Name: Edward Exam 1: 24 Exam 2: 66 GPA: F

Explanation / Answer

I have completed the code and it is working perfectely fine. Please upvote my answer.

#include <iostream>
#include <string>
using namespace std;
int ind=0;

class Student {
public:
string student_name;
string lettergrade;
float exam_1grade;
float exam_2grade;
float GPA;
void getGrade();
private:
void calcGPA();
};

void setStudentName(Student& c, string name)
{
c.student_name = name;
}
void setGrade1(Student& c, float grade1)
{
c.exam_1grade = grade1;
}
void setGrade2(Student& c, float grade2)
{
c.exam_2grade = grade2;
}
void calcGPA(Student& c)
{
c.GPA = (c.exam_1grade + c.exam_2grade) / 2;
}
void getGrade(Student &c)
{
if (c.GPA <= 100 && c.GPA >= 90)
c.lettergrade = "A";
else if (c.GPA < 90 && c.GPA >= 80)
c.lettergrade = "B";
else if (c.GPA < 80 && c.GPA >= 70)
c.lettergrade = "C";
else if (c.GPA < 70 && c.GPA >= 60)
c.lettergrade = "D";
else if (c.GPA < 60 && c.GPA >= 0)
c.lettergrade = "F";
}
void output_stu(Student& c)
{
cout << "Student: " << c.student_name << endl;
cout << "First Exam Grade: " << c.exam_1grade << endl;
cout << "Second Exam Grade: " << c.exam_2grade << endl;
cout << "Grade: " << c.lettergrade << endl;
cout << "--------------------------" << endl;
}

void addStudent(Student stu_arr[10],string name,int grade1,int grade2)
{
Student c;
setStudentName(c,name);
setGrade1(c,grade1);
setGrade2(c,grade2);
calcGPA(c);
getGrade(c);
stu_arr[ind]=c;
ind++;
}

void output(Student stu_arr[10])
{
int size=ind;
for(int i=0;i<=size;i++)
{
output_stu(stu_arr[i]);
}
}

int main(){
//the driver function
Student stu_arr[10];
addStudent(stu_arr,"Amy",95,90);
addStudent(stu_arr,"Bob",74,63);
addStudent(stu_arr,"Charlie",86,80);
addStudent(stu_arr,"Daisy",75,99);
addStudent(stu_arr,"Edward",24,66);
output(stu_arr);
return 0;
}

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