#include <iostream>
usingnamespace std;
class TestScores
{
double scores[50]; // 50 or any number you think is MAX. I, myself, am
// trying to figure out how to enter a variable
public: // literal as a constant array size.
void setScores(double s[], int arraySize)
{
for (int i= 0; i < arraySize; i++)
scores[i] = s[i];
}
void getScores(int arraySize)
{
for (int i= 0; i < arraySize; i++)
cout << scores[i] << ", ";
}
double Average(int num)
{
double sum = 0;
for (int i= 0; i < num; i++)
sum += scores[i];
return sum / num;
}
};
int main()
{
int Num_Scores = 0;
cout << "How many Test Scores? : ";
cin >> Num_Scores;
TestScores myscores;
cout << "Enter " << Num_Scores << " Test Scores." << endl;
for (int i = 0; i < Num_Scores; i++)
{
double x[Num_Scores];
cout << "Test " << i + 1 << ": ";
cin >> x[i];
myscores.setScores(x,Num_Scores);
}
cout << "All Scores: ";
myscores.getScores(Num_Scores);
cout << endl << "Average: " << myscores.Average(Num_Scores);
return 0;
}