Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In statistics, the standard deviation measures the amount of variation or disper

ID: 3761608 • Letter: I

Question

In statistics, the standard deviation measures the amount of variation or dispersion from the average. It can be calculated using the following formula Where is the standard deviation, x is each value in the data set, is the mean of all values in the data set, and n is the number of values in the data set. For your program you will ask the user for double values. Your program should stop when the user enters -99 when at this point your program will display the mean and the standard deviation from the data set. Last Modified: 10/29/2015 Sample output: Enter a value (or -99 to quit): 3 Enter a value (or -99 to quit): 5 Enter a value (or -99 to quit): 11 Enter a value (or -99 to quit): 14 Enter a value (or -99 to quit): 11 Enter a value (or -99 to quit): -99 The average is 8.8 with a standard deviation of 4.11.

must be progammed by C++

Explanation / Answer

// Example program
#include <iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
    double i;
    vector<double> arr;
    while(1)
    {
        cout<<"Enter a value (or -99 to quit): ";
        cin>>i;
        if(i==-99)
            break;
        arr.push_back(i);
    }
    int len = arr.size();
    double mean=0;
    for(i=0;i<len;i++)
        mean += arr[i];
    mean = mean/len;
    double sd=0;
    for(i=0;i<len;i++)
    {
        double t = (mean-arr[i])*(mean-arr[i]);
        //cout<<t<<' ';
        sd += t;
    }
    //cout<<sd<<' ';
    sd = sqrt(sd/len);
    cout<<"The average is "<<mean<<" with a standard deviation of "<<sd<<' ';
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote