Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. double Student::getGpa() const
  2. {
  3. // for every course, add (course units * grade) to the total,
  4. double total = 0.0;
  5. for (const auto& course : coursesCompleted)
  6. {
  7. switch (course.second)
  8. {
  9. case 'A': total += course.first.getCourseUnits() * 4.0; break;
  10. case 'B': total += course.first.getCourseUnits() * 3.0; break;
  11. case 'C': total += course.first.getCourseUnits() * 2.0; break;
  12. case 'D': total += course.first.getCourseUnits() * 1.0; break;
  13. case 'F': break;
  14. default: "Invalid Course Grade"; break;
  15. }
  16. }
  17.  
  18. // return the total / all units
  19. return static_cast<double>(total / getUnitsCompleted());
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement