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
|
#include <iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
int i;
cout << "Score report:" << endl;
cout << "Student no." << setw(10) << "Exam-1" << setw(10) << "Exam-2" << setw(10) <<
"Exam-3" << setw(10) << "Exam-4" << setw(10) << "Exam-5" << setw(10) << endl;
cout << "& Name" << endl << "*************************************************************" << endl;
string names[5] = { "Stella", "Charles", "Mike", "Nichole", "Ashden" };
double exam1[5] = { 70, 46, 90, 89, 35 };
double exam2[5] = { 78, 59, 88, 87, 33 };
double exam3[5] = { 90, 61, 79, 92, 44 };
double exam4[5] = { 82, 70, 69, 93, 61 };
double exam5[5] = { 68, 49, 92, 83, 40 };
for (i = 0; i < 5; i++)
{
cout << names[i] << "\t\t" << exam1[i] << setw(10) << exam2[i] << setw(10) << exam3[i] << setw(10) << exam4[i]
<< setw(10) << exam5[i] << endl;
}
int total[5];
double average[5];
string grades[5];
for (i = 0; i < 5;i++)
{
total[i] = exam1[i] + exam2[i] + exam3[i] + exam4[i] + exam5[i];
average[i] = total[i] / 5;
cout << names[i] << total[i] << average[i] << endl;
}
return 0;
}
|