1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
#include <cmath>
using namespace std;
double a (double s1, double s2, double s3, double s4);
double sd1 (double s1, double a);
int main()
{
double s1, s2, s3, s4;
char ans;
do
{
cout << "Input four scores" << endl;
cin >> s1>> s2>> s3 >>s4;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "The average score is " << a(s1,s2,s3,s4);
cout << "The standard deviations of the first values is " << sd1(s1,a(s1,s2,s3,s4));
cout << "Do you wanna repeat?" << endl;
cin >> ans;
}
while (ans=='y'||ans=='Y');
return 0;
}
double a (double s1, double s2, double s3, double s4)
{
return ((s1+s2+s3+s4)/4);
}
double sd1 (double s1, double a)
{
return (sqrt(pow((sd1-a),2.0)));
}
|