-
Notifications
You must be signed in to change notification settings - Fork 0
/
COP3502.cpp
182 lines (166 loc) · 3.79 KB
/
COP3502.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//
// COP3502.cpp
// COPTeamProject
//
// Created by Esteban Gonzalez on 11/12/16.
// Copyright 2016 Esteban Gonzalez. All rights reserved.
//
#include <stdio.h>
#include <string>
#include <array>
#include <iostream>
#include "COP3502.h"
using namespace std;
//constructor
COP3502::COP3502() {
for (int i = 0; i<20; i++) {
exams[i] = -1;
}
for (int i = 0; i<10; i++) {
labs[i] = -1;
homework[i] = -1;
}
for (int i = 0; i<3; i++) {
progAssignments[i] = -1;
}
}
//calcs gpa based on syllabus
//does not add in grades that are -1 which means that they have not been set
void COP3502::calcGpa() {
double tempGPA;
int numHW = 0;
double avgHW = 0;
int numProg = 0;
double avgProg = 0;
int numLabs = 0;
double avgLabs = 0;
double lablowest = 100;
double labsecondlowest = 100;
int numexams = 0;
double avgexams = 0;
for (int i = 0; i<10; i++) {
if (homework[i] != -1) {
numHW++;
avgHW += homework[i];
}
}
for (int i = 0; i < 3; i++) {
if (progAssignments[i] != -1) {
numProg++;
avgProg += progAssignments[i];
}
}
for (int i = 0; i<10; i++) {
if (labs[i] != -1) {
numLabs++;
avgLabs += labs[i];
if (labs[i]<lablowest && labs[i] == 100) {
labsecondlowest = lablowest;
lablowest = labs[i];
}
else if (labs[i]<lablowest) {
lablowest = labs[i];
}
else if (labs[i]<labsecondlowest) {
labsecondlowest = labs[i];
}
}
}
for (int i = 0; i<20; i++) {
if (exams[i] != -1) {
numexams++;
avgexams += exams[i];
}
}
avgHW = avgHW / numHW;
avgProg = avgProg / numProg;
avgLabs = avgLabs / numLabs;
avgexams = avgexams / numexams;
tempGPA = (avgHW*.20) + (avgProg*.20) + (avgLabs*.1) + (avgexams*.5);
if (tempGPA >= 95) {
gpa = 4.0;
}
else if (tempGPA >= 90 && tempGPA < 94) {
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 COP3502::updateExam(int examNum, double score) {
this->exams[examNum] = score;
}
void COP3502::updateFinal(double score) {
this->finals = score;
}
void COP3502::updateHomework(int HWNum, double score) {
this->homework[HWNum] = score;
}
void COP3502::updateLab(int labNum, double score) {
this->labs[labNum] = score;
}
void COP3502::updateProgAssignments(int progNum, double score) {
this->progAssignments[progNum] = score;
}
//prints all of the grade values for the class
void COP3502::printAll()
{
cout << courseName << endl << "Homework: " << endl;
for (size_t i = 0; i < homework.size(); i++) {
if (homework[i] >= 0) {
cout << i + 1 << ". " << homework[i] << endl;
}
}
cout << endl;
cout << "Programming Assignments: " << endl;
for (size_t i = 0; i < progAssignments.size(); i++) {
if (progAssignments[i] >= 0) {
cout << i + 1 << ". " << progAssignments[i] << endl;
}
}
cout << endl;
cout << "Labs: " << endl;
for (size_t i = 0; i < labs.size(); i++) {
if (labs[i] >= 0) {
cout << i + 1 << ". " << labs[i] << endl;
}
}
cout << endl;
cout << "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;
}