forked from haxo93/gpa_member_func
-
Notifications
You must be signed in to change notification settings - Fork 0
/
student.cpp
49 lines (39 loc) · 773 Bytes
/
student.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include "student.h"
using namespace std;
Student::Student()
{
name = "";
credits = 0;
qp = 0;
}
Student::Student(string tempname,int tempcredits, double tempqp)
{
name = tempname;
if (tempcredits == 0 && tempqp == 0)
return;
if (tempcredits > 0)
credits = tempcredits;
else
credits = 0;
if (tempqp > 0)
qp = tempqp;
else
qp = 0;
}
double Student::computeGPA()
{
if (credits > 0 || qp > 0)
return qp/credits;
else
return 0.0;
}
void Student::addGrade(string tempgrade, int tempcredits)
{
credits += tempcredits;
double v = findGradeValue(tempgrade);
qp += tempcredits * v;
}