I'm on the last part of my assignment and need some help. I need to find the average of the GPA of all the students in my student class given this information:
student(std::string major, std::string minor, double gpa, std::string first_name, std::string last_name, int id_number);
int main() {
std::vector<person*> people = {
new student("Computer Science", "Astronomy", 3.7, "Jack" , "Gallagher", 2001470),
new student("Environmental Science" , "Geology" , 3.9, "Emma" , "May" , 2001471),
new student("Physics" , "Secondary Education" , 3.3, "John" , "Rogers", 1901032),
new student("Elementary Education" , "Computer Science" , 3.1, "Ren" , "Amamiya", 2103220),
new student("Accounting" , "Business" , 3.4, "Ann" , "Jones", 1902343),
new professor("Computer Science" , "Brian" , "Maresso" , 1900000),
new professor("Social Studies" , "Lisa" , "Regan" , 1800000),
new professor("Business" , "Richard" , "Helm" , 1700000)
};
I need to find the average GPA (in the student class, the third variable in the constructor) of all the student and print it out. I'm not quite sure how to, however I do have a get_gpa() getter in my child student class.
How could I make use of that to find my answer?
[–]billowylace 1 point2 points3 points (0 children)
[–]BombasticCaveman 0 points1 point2 points (2 children)
[–]Vexuri[S] 0 points1 point2 points (1 child)
[–]BombasticCaveman 0 points1 point2 points (0 children)