Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double Student::getGpa() const
- {
- // for every course, add (course units * grade) to the total,
- double total = 0.0;
- for (const auto& course : coursesCompleted)
- {
- switch (course.second)
- {
- case 'A': total += course.first.getCourseUnits() * 4.0; break;
- case 'B': total += course.first.getCourseUnits() * 3.0; break;
- case 'C': total += course.first.getCourseUnits() * 2.0; break;
- case 'D': total += course.first.getCourseUnits() * 1.0; break;
- case 'F': break;
- default: "Invalid Course Grade"; break;
- }
- }
- // return the total / all units
- return static_cast<double>(total / getUnitsCompleted());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement