Write a function that computes the average and standard deviation of four scores. The standard deviation is defined to be the square root of the average of the four values: (si − a )2, where a is the average of the four scores s1, s2, s3, and s4. The function will have six parameters and will call two other functions. Embed the function in a program that allows you to test the function again and again until you tell the program you are finished.

Respuesta :

Answer:

#include<iostream>

#include<cmath>

using namespace std;

double calAvg(double s1, double s2,double s3, double s4);

double calStandardDeviation(double s1, double s2,double s3, double s4,double average,int n);

void main()

{

 double s1,s2,s3,s4;

double avg,StandardDeviation;

char option;

   do

{

 cout<<"Enter s1:";

 cin>>s1;

 cout<<"Enter s2:";

 cin>>s2;

 cout<<"Enter s3:";

 cin>>s3;

        cout<<"Enter s4:";

 cin>>s4;

 avg=calcAvg(s1,s2,s3,s4);

        sdeviation=calcStandardDeviation(s1,s2,s3,s4,avg,4);

 cout<<"Standard deviation:"<<sdeviation<<endl;

 cout<<"Do you want to continue then press y:";

         cin>>option;

}

       while (option='y');

}

double Average(double s1, double s2,double s3, double s4)

{

return (s1+s2+s3+s4)/4;

}

double calcStandardDeviation(double s1, double s2,double s3, double s4, double mean,int n)

{

double sd;

sd=(pow((s1-mean),2)+pow((s2-mean),2)+

                     pow((s3-mean),2)+pow((s4-mean),2))/n;

sd=sqrt(sd);

return sd;

}

In this exercise we have to use the knowledge in computer language to write a code in C, like this:

the code can be found in the attached image

to make it simpler we have that the code will be given by:

#include<iostream>

#include<cmath>

using namespace std;

double calAvg(double s1, double s2,double s3, double s4);

double calStandardDeviation(double s1, double s2,double s3, double s4,double average,int n);

void main()

{

double s1,s2,s3,s4;

double avg,StandardDeviation;

char option;

  do

{

cout<<"Enter s1:";

cin>>s1;

cout<<"Enter s2:";

cin>>s2;

cout<<"Enter s3:";

cin>>s3;

       cout<<"Enter s4:";

cin>>s4;

avg=calcAvg(s1,s2,s3,s4);

       sdeviation=calcStandardDeviation(s1,s2,s3,s4,avg,4);

cout<<"Standard deviation:"<<sdeviation<<endl;

cout<<"Do you want to continue then press y:";

        cin>>option;

}

      while (option='y');

}

double Average(double s1, double s2,double s3, double s4)

{

return (s1+s2+s3+s4)/4;

}

double calcStandardDeviation(double s1, double s2,double s3, double s4, double mean,int n)

{

double sd;

sd=(pow((s1-mean),2)+pow((s2-mean),2)+

                    pow((s3-mean),2)+pow((s4-mean),2))/n;

sd=sqrt(sd);

return sd;

}

See more about C code at brainly.com/question/25870717

Ver imagen lhmarianateixeira