1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
#include <vector>
using namespace std;
struct Boundary{ int min; char grade; };
vector<Boundary> boundaries = { { 90, 'A' }, { 85, 'B' }, { 80, 'C' }, { 75, 'D' }, { 0, 'F' } };
int main()
{
const int N = 5;
double sum = 0, mark;
cout << "Enter your grades for Filipino, Computing, Mathematics, English, Science:\n";
for ( int i = 0; i < N; i++ )
{
cin >> mark;
sum += mark;
}
double average = sum / N;
int GPA = average + 0.5;
int p = 0;
while ( boundaries[p].min > GPA ) p++;
cout << "Average mark = " << average << " Grade = " << boundaries[p].grade << '\n';
}
| |