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
|
#include <iostream>
using namespace std;
void getScores (float testScore[10]);
int getGrades (float testScore[10], float totalScore);
void displayInfo(float avg,int A, int B, int C, int D, int F);
void main (void)
{
int i = 0;
float testScore [10];
getScores (float testScore[10]);
getGrades (float testScore[10], float totalScore);
displayInfo(float avg,int A, int B, int C, int D, int F);
system("pause");
}
void getScores (float testScore[10])
{
for (int i=0; i<10; i++)
{
cout << "Enter test score " << i + 1 << ": ";
cin >> testScore[i];
}//for
cout << '\n';
}
int getGrades (float testScore[10], float totalScore);
{
int i(0);
int A(0);
int B(0);
int C(0);
int D(0);
int F(0);
float avg = 0;
float totalScore = 0;
for (i=0; i<10; i++)
{
if (testScore[i] >= 92.0)
{
cout << "Person " << i + 1 << " has a score of: " << testScore[i] << " which is an A" << endl;
A++;
}//if
else if (testScore[i] >= 84.0)
{
cout << "Person " << i + 1 << " has a score of: " << testScore[i] << " which is a B" << endl;
B++;
}//else if
else if (testScore[i] >= 75.0)
{
cout << "Person " << i + 1 << " has a score of: " << testScore[i] << " which is a C" << endl;
C++;
}//else if
else if (testScore[i] >= 65.0)
{
cout << "Person " << i + 1 << " has a score of: " << testScore[i] << " which is a D" << endl;
D++;
}//else if
else //(testScore[i] < 65.0)
{
cout << "Person " << i + 1 << " has a score of: " << testScore[i] << " which is a F" << endl;
F++;
}//else if
totalScore += testScore[i];
}//for
cout << '\n';
avg = totalScore/10.0;
return avg;
}
void displayInfo(float avg,int A, int B, int C, int D, int F)
{
cout << "The class average is: " << avg << "%" << '\n' << '\n';
cout << A << " people received the grade A\n";
cout << B << " people received the grade B\n";
cout << C << " people received the grade C\n";
cout << D << " people received the grade D\n";
cout << F << " people received the grade F\n\n";
}
|