Fantasy F.

asked • 09/12/21

complete the member function ( fdeviation(….)) of class Stats :

#include <iostream>

#include <cmath>

using namespace std;

class Stats

{ double mean, deviation;

public:

/** Function for computing mean of an array of double values */

double findmean(double x[], int size)

{

double sum = 0;

for (int i = 0; i < size; i++)

sum += x[i];

mean = sum * 1.0 / size;

return mean;

}

/** Function for computing deviation of double values */

double fdeviation(double x[], int size)

{

// this is to be completed

}

};



class DOO5441_cw_10

// this class is to keep marks and statistics for 10 students

{ double marks[10];

Stats s;

public:

void set()

{

cout << "Enter 10 marks: ";

for (int i = 0; i < 10; i++)

{

cin >> marks[i];

}

}

void printstats()

{ cout << "The mean is " <<s.findmean(marks, 10)<<endl;

cout << "The standard deviation is " << s.fdeviation(marks, 10) << endl;

}

};

int main()

{ DOO5441_cw_10 ob;

ob.set();

ob.printstats();

return 0;

}

1 Expert Answer

By:

Andrew R. answered • 09/12/21

Tutor
New to Wyzant

Experienced Teacher and Tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.