-
Notifications
You must be signed in to change notification settings - Fork 0
/
LetterGrade.cpp
92 lines (78 loc) · 1.58 KB
/
LetterGrade.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
#include "LetterGrade.h"
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
void LetterGrade::createfile(string fileName, vector<string> name, vector<vector<double>> grades)
{
ofstream create;
double accum = 0;
create.open(fileName + ".csv");
vector<string> header = {"Student Name", "Grade" , "Average", "Letter Grade" };
//creates a header line for grade #
create << header[0] << ",";
for (int h = 0; h < grades.size(); h++)
{
create << header[1] << " #" << (h + 1) << ",";
}
//Creates header line for Average and Letter Grade
create << header[2];
create << "," << header[3] << endl;
for (int o = 0; o < name.size(); o++)
{
create << name[o];
for (int n = 0; n < grades.size(); n++)
{
create << "," << grades[o][n];
accum = grades[n][o] + accum;
}
accum = accum / grades.size();
create << "," << accum;
LetterGrade final;
create << "," << final.getLetterGrade(accum);
accum = 0;
create << endl;
}
}
string LetterGrade::getLetterGrade(double f)
{
if (f >= 100)
{
return "A+";
}
else if (f >= 93 && f <= 99.99)
{
return "A";
}
else if (f <= 92.99 && f >= 90)
{
return "A-";
}
else if (f >= 87.99 && f <= 89.99)
{
return "B+";
}
else if (f >= 83 && f <= 86.99)
{
return "B";
}
else if (f >= 80 && f <= 82.99)
{
return "B-";
}
else if (f >= 77 && f <= 79.99)
{
return "C+";
}
else if (f >= 73 && f <= 76.99)
{
return "C";
}
else if (f >= 70 && f <= 72.99)
{
return "C-";
}
else {
return "F";
}
}