ok Thanks for the input! this is what i have
Code:
#include <iostream>using namespace std;
class TestScores
{
private:
double *score;
int numScores;
public:
void getScore();
void sortScore(double score[], int numScores);
void showScore(const double score[], int numScores);
double getAverage(double*, int);
};
void TestScores::getScore()
{
score= new double [numScores];
for(int i=0;i<numScores;i++)
{
cout<<"Enter the score for test#"<<i+1;
cin>>score[i];
while(numScores<0||numScores>10)
{
cout<<"Error! Invalid score. Please try again."<<endl;
cin>>score[i];
}
}
}
double TestScores::getAverage(double *score,int numScores)
{
double total=0.0,avg;
for(int i=0;i<numScores;i++)
{
total+=score[i];
}
avg=total/numScores;
cout<<"The average is"<<avg;
return avg;
}
void TestScores::sortScore(double score[], int numScores)
{
int temp;
bool swap;
do
{
swap=false;
for(int count=0;count<(numScores-1);count++)
{
if(score[count]>score[count+1])
{
temp=score[count];
score[count]=score[count+1];
score[count+1]=temp;
swap=true;
}
}
}while(swap);
}
void TestScores::showScore(const double score[], int numScores)
{
for(int count=0;count<numScores;count++)
cout<<score[count]<<" ";
cout<<endl;
}
int main()
{
int size;
double *grades;
TestScores student;
student.getScore();
student.sortScore( grades,size);
student.getAverage(grades,size);
student.showScore(grades,size);
delete grades;
system("pause");
}