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
|
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
int i;
const string GRADE_LETTERS[] = { "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F" };
const double GRADE_BOUNDS[] = { 92.0, 90.0, 87.0, 82.0, 80.0, 77.0, 72.0, 70.0, 67.0, 62.0, 60.0, 0.0 };
const int GRADE_COUNT = sizeof(GRADE_BOUNDS) / sizeof(GRADE_BOUNDS[0]);
const double SENTINEL = -1.0;
const int SIZE = 4;
double inScore;
double studentScores[SIZE];
string studentGrades[SIZE];
cout << "Enter the scores, etc., " << SENTINEL << " to end input..." << endl;
cin >> inScore;
i = 0;
while (inScore != SENTINEL)
{
studentScores[i] = inScore;
++i;
cin >> inScore;
}
for (i = 0; i < SIZE; ++i)
{
if ( studentScores[i] >= GRADE_BOUNDS[i])
{
cout << GRADE_LETTERS[i];
}
}
system("pause");
return 0;
}
|