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: "<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hi, I am having some trouble with my c++ homework question. I have provided my code for the question below.

#include<iostream>
#include<string>
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: "<<a.setName()<<endl;
cout<<"Exam1 grade: "<< a.getExam1()<<endl;
cout<<"Exam2 grade: "<< a.getExam2()<<endl;
cout<<"Final Grade: "<< a.getGrade()<<endl;
}

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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to Coding
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education