-
Notifications
You must be signed in to change notification settings - Fork 0
/
COT3100.cpp
99 lines (90 loc) · 1.93 KB
/
COT3100.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
// COT3100.cpp
// COPTeamProject
//
// Created by Esteban Gonzalez on 11/12/16.
// Copyright 2016 Esteban Gonzalez. All rights reserved.
//
#include <stdio.h>
#include <string>
#include <iostream>
#include <array>
#include "COT3100.h"
using namespace std;
//constructor
Cot3100::Cot3100() {
for (int i = 0; i<20; i++) {
exams[i] = -1;
}
}
//calcs gpa based on syllabus
//does not add in grades that are -1 which means that they have not been set
void Cot3100::calcGpa() {
double tempGPA = 0;
int numexams = 0;
double avgexam = 0;
for (int i = 0; i<4; i++) {
if (exams[i] != -1) {
numexams++;
avgexam += exams[i];
}
}
avgexam = avgexam / numexams;
tempGPA = (avgexam*.72) + (finals*.28);
if (tempGPA >= 93) {
gpa = 4.0;
}
else if (tempGPA >= 90 && tempGPA < 93) {
gpa = 3.67;
}
else if (tempGPA >= 87 && tempGPA < 90) {
gpa = 3.33;
}
else if (tempGPA >= 83 && tempGPA < 87) {
gpa = 3;
}
else if (tempGPA >= 80 && tempGPA < 83) {
gpa = 2.67;
}
else if (tempGPA >= 77 && tempGPA < 80) {
gpa = 2.33;
}
else if (tempGPA >= 73 && tempGPA < 77) {
gpa = 2;
}
else if (tempGPA >= 70 && tempGPA < 73) {
gpa = 1.67;
}
else if (tempGPA >= 67 && tempGPA < 70) {
gpa = 1.33;
}
else if (tempGPA >= 63 && tempGPA < 67) {
gpa = 1;
}
else if (tempGPA >= 60 && tempGPA < 63) {
gpa = 0.67;
}
else {
gpa = 0;
}
}
//setters for the private variables
void Cot3100::updateExam(int examNum, double score) {
this->exams[examNum] = score;
}
void Cot3100::updateFinal(double score) {
this->finals = score;
}
//prints all of the grade values for the class
void Cot3100::printAll()
{
cout << courseName << endl << "Exams: " << endl;
for (size_t i = 0; i < exams.size(); i++) {
if (exams[i] >= 0) {
cout << i + 1 << ". " << exams[i] << endl;
}
}
cout << endl;
cout << "Finals: " << finals << endl;
cout << endl;
}