Stats | Solution
Programming Assignment
Some Statistical Analysis
Solution Below
OUTPUT FOR RUN #1:
#include <iostream>
#include <math.h>
using namespace std;
int main ( )
{
float A, B, C, D, E, F, G, sum, mean;
double variance, StandardDeviation;
cout << " I will give you the sum, mean, and standard deviation "<< "of any seven numbers." <<endl;
cout << "Type each number, followed by the enter key." <<endl <<endl;
// user input data
cout << "Number=?";
cin >> A;
cout << "Number=?";
cin >> B;
cout << "Number=?";
cin >> C;
cout << "Number=?";
cin >> D;
cout << "Number=?";
cin >> E;
cout << "Number=?";
cin >> F;
cout << "Number=?";
cin >> G;
// print out data
cout <<endl;
cout << " You entered :" <<endl;
cout << '\t' <<A<<endl;
cout << '\t' <<B<<endl;
cout << '\t' <<C<<endl;
cout << '\t' <<D<<endl;
cout << '\t' <<E<<endl;
cout << '\t' <<F<<endl;
cout << '\t' <<G<<endl;
// calculate the sum
sum = (A+B+C+D+E+F+G);
cout << "the sum is: " <<sum<<endl;
// calculate the mean
mean = sum/7;
cout << "the mean is: " <<mean<<endl;
// calculate standard deviation
variance = ( (A-mean)*(A-mean)+ (B-mean)*(B-mean)+ (C-mean)*(C- mean)
+ (D-mean)*(D-mean)+ (E-mean)*(E-mean) +(F-mean)*(F-mean)
+ (G-mean)*(G-mean))/6;
StandardDeviation=sqrt(variance);
cout << " The standard deviation is " <<StandardDeviation <<endl << endl;
return 0;
} // end main
.