Hi, I am having some trouble with my c++ homework question. I have provided my code for the question below. #include #include using namespace std; class Student{ private: string name; int...


Hi, I am having some trouble with my c++ homework question.

I have provided my code for the question below.





#include
#include
using namespace std;
class Student{
private:
string name;
int exam_1grade,exam_2grade;
double calcGPA(){
return (exam_1grade + exam_2grade)/2.0;
}
public:
Student(){
name =" ";
exam_1grade = 0;
exam_2grade = 0;
}
Student(string name, int Exam1, int Exam2){
name = name;
exam_1grade = Exam1;
exam_2grade = Exam2;
}
void setName(string n) {
name = n;
}
void setExam1(int Exam1){
exam_1grade = Exam1;
}
void setExam2(int Exam2){
exam_2grade=Exam2;
}
string setName(){
return name;
}
int getExam1(){
return exam_1grade;
}
int getExam2(){
return exam_2grade;
}
string getGrade(){
double gpa = calcGPA();
if(gpa >= 90 ) return "A";
else if(gpa >= 80 ) return "B";
else if(gpa >= 70 ) return "C";
else if(gpa >= 60 ) return "D";
else return "F";
}
};
int main(){
Student a;
a.setName("David");
a.setExam1(90);
a.setExam2(80);
cout<"name:><><"exam1 grade:=""><><>
cout<"exam2 grade:=""><><>
cout<"final grade:=""><><>
}




Using the class from
problem 1, replace main with the following:
a. Implement a partially filled array of type Student named students of capacity
10.
b. Implement a non-member addStudent() function that:
1. Creates a new student with data populated by input parameters.
2. Adds the new student to the students array.
c. Implement a non-member output() function that:
1. Outputs all student data in the students array as displayed in the output
example (see next page).
d. Main should use the addStudent and output functions to create five students
and display their content to the console (see next page).
f. Test all functions use following main.





int main(){
int capacity = 10;
Student students[capacity];
int num = 0;
addStudent(students,capacity,num,"Amy",95,90);
addStudent(students,capacity,num,"Bob",74,63);
addStudent(students,capacity,num,"Charlie",86,80);
addStudent(students,capacity,num,"Daisy",75,90);
addStudent(students,capacity,num,"Edward",24,66);
output(students,num);
}







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: David
Exam 1: 24
Exam 2: 66
GPA: F

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here