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
|
#include <iostream>
using namespace std;
void printarray (int arg[], int length) {
for (int n=0; n<length; ++n)
cout << arg[n] << ' ';
cout << '\n';
double Grade1;
double Grade2;
double Grade3;
double Grade4;
double AvgGrade;
double Total = 0;
int Students = 0;
int n = 0;
int stu;
Total = (Grade1 + Grade2 + Grade3+ Grade4);
AvgGrade = (Total / 4);
n = n + 1;
if ( AvgGrade >= 90)
cout << " letter grade: A!\n";
else
if ( AvgGrade >= 80)
cout << " letter grade: B.\n";
else
if ( AvgGrade >= 70)
cout << " letter: grade: C.\n";
else
if ( AvgGrade >= 60)
cout << " letter grade: D.\n";
else
cout << " letter grade: F.\n";
cout << "Enter the number of students in class : ";
cin >> Students;
while (n < Students) {
cout <<" input student number \n";
cin>>stu;
cout << "Please enter four grades for student ";
cin >> Grade1;
cin >> Grade2;
cin >> Grade3;
cin >> Grade4;
cout << "\n";
}
int main ()
{
int firstarray[] = {"Student number","Grade 1","Grade 2","Grade 3","Grade 4","Average"};
int secondarray[] = {stu, Grade1, Grade1, Grade1, Grade1, AvgGrade};
printarray (firstarray,6);
printarray (secondarray,6);
return 0;
}
|