-
Notifications
You must be signed in to change notification settings - Fork 0
/
PHY2049.cpp
156 lines (141 loc) · 3.21 KB
/
PHY2049.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
//
// PHY2049.cpp
// COPTeamProject
//
// Created by Esteban Gonzalez on 11/12/16.
// Copyright 2016 Esteban Gonzalez. All rights reserved.
//
#include <stdio.h>
#include <string>
#include "PHY2049.h"
#include <iostream>
#include <array>
//constructor that initializes everything to -1
Phy2049::Phy2049() {
for (int i = 0; i<20; i++) {
exams[i] = -1;
}
for (int i = 0; i<10; i++) {
quizzes[i] = -1;
}
for (int i = 0; i<13; i++) {
homework[i] = -1;
}
}
//calculates the gpa for the given classed based on the grade values set
//calculates the gpa based on the syllabus specifications
void Phy2049::calcGpa() {
double tempGpa;
int numquiz = 0;
double avgquiz = 0;
int numHW = 0;
double avgHW = 0;
int numexam = 0;
double avgexam = 0;
for (int i = 0; i<10; i++) {
if (quizzes[i] != -1) {
numquiz++;
avgquiz += quizzes[i];
}
}
for (int i = 0; i<13; i++) {
if (homework[i] != -1) {
numHW++;
avgHW += homework[i];
}
}
for (int i = 0; i<10; i++) {
if (exams[i] != -1) {
numexam++;
avgexam += exams[i];
}
}
avgquiz = (avgquiz / numquiz) / .9;
if (avgquiz>100) {
avgquiz = 100;
}
avgHW = (avgHW / numHW) / .9;
if (avgHW>100) {
avgHW = 100;
}
avgexam = avgexam / numexam;
tempGpa = (avgexam * .5) + (avgHW * .05) + (avgquiz * .20) + (hittPoints*.05) + (finals*.25);
if (tempGpa >= 85) {
gpa = 4.0;
}
else if (tempGpa >= 80 && tempGpa < 85) {
gpa = 3.67;
}
else if (tempGpa >= 75 && tempGpa < 80) {
gpa = 3.33;
}
else if (tempGpa >= 70 && tempGpa < 75) {
gpa = 3;
}
else if (tempGpa >= 65 && tempGpa < 70) {
gpa = 2.67;
}
else if (tempGpa >= 60 && tempGpa < 65) {
gpa = 2.33;
}
else if (tempGpa >= 55 && tempGpa < 60) {
gpa = 2;
}
else if (tempGpa >= 50 && tempGpa < 55) {
gpa = 1.67;
}
else if (tempGpa >= 45 && tempGpa < 50) {
gpa = 1.33;
}
else if (tempGpa >= 40 && tempGpa < 45) {
gpa = 1;
}
else if (tempGpa >= 35 && tempGpa < 40) {
gpa = 0.67;
}
else {
gpa = 0;
}
}
//setters for private variables
void Phy2049::updateExam(int examNum, double score) {
this->exams[examNum] = score;
}
void Phy2049::updateFinal(double score) {
this->finals = score;
}
void Phy2049::updateQuiz(int quizNum, double score) {
this->quizzes[quizNum] = score;
}
void Phy2049::updateHomework(int homeworkNum, double score) {
this->homework[homeworkNum] = score;
}
void Phy2049::updateHittPoints(double score) {
this->hittPoints = score;
}
//prints all of the grades for this class
void Phy2049::printAll() {
cout << courseName << endl << "Homework: " << endl;
for (size_t i = 0; i < homework.size(); i++) {
cout << i + 1 << ". " << homework[i] << endl;
}
cout << endl;
cout << "Hittpoints: " << hittPoints << 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 << "Quizzes: " << endl;
for (size_t i = 0; i < quizzes.size(); i++) {
if (quizzes[i] >= 0) {
cout << i + 1 << ". " << quizzes[i] << endl;
}
}
cout << endl;
cout << "Finals: " << finals << endl;
cout << endl;
}