#include <iostream>
#include <cmath>

using namespace std;

//explains program to user and directs them to enter appropriate values.
void printDirections();

//returns the arithmetic mean of the four arguments.
double average(double s1, double s2, double s3, double s4);

//returns the standard deviation of the four arguments.
double stdDev(double s1, double s2, double s3, double s4);

// ===================================
// main function
// ===================================
int main()
{
double s1, s2, s3, s4;
double avg, sd;
char ans;
do
{
printDirections();
cin >> s1 >> s2 >> s3 >> s4;
avg = average(s1, s2, s3, s4);
sd = stdDev(s1, s3, s3, s4);
cout << "The Average is:    ";
cout << avg << endl;
cout << "The Standard Deviation is:    ";
cout << sd << endl;
cout << "Y/y continues, any other quits." << endl;
cin >> ans;
}
while(ans == 'Y' || ans == 'y');
return 0;
}

// ===================================
// print directions
// ===================================
//explains program to user and directs them to enter appropriate values.

void printDirections()
{
cout << "Enter four values, separated by white space and terminated by a \"return\"" << endl;
cout << "I will compute the average and standard deviation." << endl;
}

// ===================================
// compute average
// ===================================
//returns the arithmetic mean of the four arguments.

double average(double s1, double s2, double s3, double s4)
{
double ave;
ave = (s1 + s2 + s3 + s4)/4;
return ave;
}

// ===================================
// compute standard deviation
// ===================================
//returns the standard deviation of the four arguments.

double stdDev(double s1, double s2, double s3, double s4)
{
double deviate , bs1, bs2, bs3, bs4, smsqdv;
double a = average(s1, s2, s3, s4);
bs1 = pow(s1 - a , 2);
bs2 = pow(s2 - a , 2);
bs3 = pow(s3 - a , 2);
bs4 = pow(s4 - a , 2);
smsqdv = (bs1 + bs2 + bs3 + bs4)/3 ;
deviate = sqrt(smsqdv);
return deviate;
}