Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. The first Class example was given in class. Write the member functions for th

ID: 3858486 • Letter: 1

Question

1. The first Class example was given in class. Write the member functions for the calculation of mean and standard deviation. Highlight your code so that I can easily find it in the program You should test your functions in the main function. #include 2 using namespace std; 3 class AForEveryone i 4private: int *grade, gradeSize; double max, min, mean, stdv; 6 7 public: AForEveryone (int *gradePtr, int size) grade-gradePtr; grade size = size; max - 0.0 min = 0.0; mean - 0.0; stdv - 0.0; 10 12 13 14 15 16 17 18 19 20 21 AForEveryone () f max = 0 . 0 ; min = 0.0; mean - 0.0; stdv = 0.0; void receiveGrade (int *gradePtr, int size) 23 24 25 26 27 28 29 30 31 32 grade-gradePtr; gradeSize - size; double getMax) I return max; double getMin) i return min; double getMean ) i return mean; 34 35 36 37 38 39 40 41 double getStdv) i return stdv; void computeMax ) int *tempGrade = grade ; int temp; for (int i=0; i

Explanation / Answer

Put these functions after computeMin() function inside class


float calculateMean()
{
  
    float sum = 0.0, mean;

    int i;

    for(i = 0; i < gradeSize; ++i)
    {
        sum += grade[i];
    }

    mean = sum/gradeSize;
   return mean;
}

float calculateSD()
{
   float mean = calculateMean();
    float sum = 0.0, sd = 0.0;

    int i;

    for(i = 0; i < gradeSize; ++i)
    {
        sum += grade[i];
    }

    mean = sum/gradeSize;

    for(i = 0; i < gradeSize; ++i)
        sd += pow(grade[i] - mean, 2);

    return sqrt(sd / gradeSize);
}