Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double Student::computeMajorGpa() {
- double cumulativeGPA = 0;
- int numCourses = 0;
- int i;
- for (i = 0; i <coursesTaken.size(); i++) {
- if (coursesTaken[i].name == "CS" || coursesTaken[i].name == "MATH") {
- numCourses++;
- switch(coursesTaken[i].grade) {
- case 'A': cumulativeGPA += 4.0; break;
- case 'B': cumulativeGPA += 3.0; break;
- case 'C': cumulativeGPA += 2.0; break;
- case 'D': cumulativeGPA += 1.0; break;
- default: cumulativeGPA += 0.0; // F
- }
- }
- }
- if (numCourses == 0)
- return -1;
- else
- return cumulativeGPA / numCourses;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement