-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculate.h
69 lines (61 loc) · 1.59 KB
/
calculate.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CALCULATE_H
#define CALCULATE_H
#include <iostream>
#include <unordered_map>
#include <vector>
#include <string>
#include <algorithm>
struct Entry{
std::string course_name;
std::string grade;
double credits;
};
struct Semester{
std::vector<Entry> entries;
double total_credits;
double quality_points;
double gpa;
};
class CourseComp{
private:
std::string value;
public:
CourseComp(std::string &value_in) : value(value_in){}
bool operator()(Entry a){
return a.course_name == value;
}
};
class GradeComp{
private:
std::string value;
public:
GradeComp(std::string &value_in) : value(value_in){}
bool operator()(Entry a){
return a.grade == value;
}
};
class CreditComp{
private:
double value;
public:
CreditComp(double &value_in) : value(value_in){}
bool operator()(Entry a){
return a.credits == value;
}
};
class GPA{
private:
std::unordered_map<std::string, Semester> transcript;
const std::unordered_map<std::string, double> grade_value =
{{"A", 4.0}, {"A-", 3.7}, {"B+", 3.3}, {"B", 3.0}, {"B-", 2.7}, {"C+", 2.3}, {"C", 2.0}, {"C-", 1.7}, {"D+", 1.3}, {"D", 1.0}, {"D-", 0.7}, {"E", 0.0}};
public:
GPA();
void readInput();
bool exists(std::string &command, std::string &input, std::unordered_map<std::string, Semester>::iterator &it);
void insert(std::string &command);
void calculate_semester(Semester &semester);
void printCumulative(std::string &command);
void deleteEntry(std::string &command);
~GPA();
};
#endif