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
|
#include <iostream>
using namespace std;
struct GradeInfo
{
const char *name;
const char *initials;
int high;
};
GradeInfo grades[] = {
{"FAIL", "F", 49},
{"PASS", "P", 59},
{"UPPER PASS", "UP", 69},
{"CREDIT", "C", 79},
{"DISTINCTION", "D", 89},
{"HIGH DISTINCTION", "HD", 100},
};
int
main()
{
int num1, num2, num3, num4, Average;
cout << "Enter your grade in the following units." << endl;
cout << "COT 211=";
cin >> num1;
cout << "COT 212=";
cin >> num2;
cout << "COT 213=";
cin >> num3;
cout << "CLE 211=";
cin >> num4;
Average = (num1 + num2 + num3 + num4) / 4;
cout << "Your average grade is" << '\t' << Average << "/100" << endl;
bool found = false;
for (auto & grade:grades) {
if (Average <= grade.high) {
cout << "Equivalent to " << grade.initials << '\t'
<< "its a " << grade.name << '\n';
found = true;
break;
}
}
if (!found) {
cout << "Come to school\n";
}
return 0;
}
|