In: Computer Science
Write a program that calculates mean and standard deviation for four user entered values. The most common measures of a sample are the mean and the standard deviation. the mean is the sum of the values divided by the number of elements in the data set. The dispersion - or spread in the values - is measured by the standard deviation The equation for the mean is x¯ = x1 + x2 + · · · + xn The equation for the standard deviation is sx = √ (x1 − x¯) 2 + (x2 − x¯) 2 + · · · + (xn − x¯) 2 n − 1 Your program will have the user enter four values (all doubles), You might call them x1, x2,x3,and x4. The program will then pass these four values to a function called mean that will calculate and return the mean of the four values. The mean and the four values will then be passed to a second function called stdev which will calculate and return the standard deviation of the four values. You program should be using functions. There will be a function printHeader that prints the splash screen, a function mean that calculates the mean, a function stdev that calculates the standard deviation, and a function printResults that prints the four values, their mean, and their standard deviation Your program must also include comments with your name, the date, and a short description of the project. It must also print this information as a splash screen at the beginning of the program run. It should print like:
X: 4.00, 7.00, 1.00, 10.00
Mean: 5.50
Std Dev: 3.87
This needs to be done in C++. Below is the format:
//
//   Name
// 1 October 2020
//   Program to calculate the mean and standard
deviation
//
//   Pound includes - will need the string and cmath
libraries
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;
//   Function Prototypes - Need to add three more. One
for mean, one for
// standard deviation, and one for the printResults
void printHeader(string, string);
int main(void) {
   // Splash Screen
   printHeader("1 October 2020", "Calculating
Statistics");
  
   //   Declare and Initialize all of the
variables
   //   Will need doubles for the four data
points, as well as a double
// for the mean and one for the standard deviation
  
  
   //   Prompt for entering data - you must
enter four values
  
  
   // Pass the four data variables to a function that
returns the mean
  
  
  
   //   Pass the four data variables and the
mean to a function that returns
// the standard deviation
  
  
  
  
   //   Print the results
   //   Include the original values and the
mean and the standard
// DO NOT PRINT IT HERE - pass the variables to a printResults
function
  
  
  
  
  
   return 0;
}
//   Function Definitions
void printHeader(string dueDate, string description) {
//   PRINTHEADER void printHeader(string, string) prints
the splash screen
//   using the two strings that are passed to the
function from the driver.
//  
//   Name:   
//   Date:
//
  
   //   Print the splash screen
   cout << endl;
   cout << "Your Name Here" << endl;
   cout << "CMPSC 101" << endl;
   cout << dueDate << endl;
   cout << description << endl;
   cout << endl;
   return;
}
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;
void printHeader(string, string);
/* function to calculate mean of four data points passed to functions */
double calcMean(double dataPoint1, double dataPoint2, double dataPoint3, double dataPoint4)
{
        double mean;
        mean = (dataPoint1 + dataPoint2 + dataPoint3 + dataPoint4) / 4;    //formula applied for mean
          
        return mean;
}
/* function to calculate standard deviation of four data points*/
double calcStandardDeviation(double dataPoint1, double dataPoint2, double dataPoint3, double dataPoint4, double mean)
{
        double standardDeviation;
        /* applied formula to calculate standard deviation. sqrt and pow functions are from cmath */
        standardDeviation = sqrt((pow((dataPoint1 - mean), 2) + pow((dataPoint2 - mean), 2) + pow((dataPoint3 - mean), 2) + pow((dataPoint4 - mean), 2)) / 3);
        return standardDeviation;
}
/* function to print results */
/* fixed and setprecision(2) is used to fix two digits after decimal in output*/
void printResults(double dataPoint1, double dataPoint2, double dataPoint3, double dataPoint4, double mean, double standardDeviation)
{
        cout << "X: " <<fixed<<setprecision(2)<< dataPoint1 << ", " << dataPoint2 << ", " << dataPoint3 << ", " << dataPoint4 << endl;
        cout << "Mean: " <<fixed<<setprecision(2)<< mean<<endl;
        cout << "Std Dev: " <<fixed<<setprecision(2)<< standardDeviation<<endl;
}
int main(void) {
        // Splash 
        printHeader("1 October 2020", "Calculating Statistics");
        double dataPoint1, dataPoint2, dataPoint3, dataPoint4;
        double mean, standardDeviation;
        cout << "Enter four data points :: ";
        cin >> dataPoint1 >> dataPoint2 >> dataPoint3 >> dataPoint4;
        mean = calcMean(dataPoint1, dataPoint2, dataPoint3, dataPoint4);  //called calculate mean function with four data points
        standardDeviation = calcStandardDeviation(dataPoint1, dataPoint2, dataPoint3, dataPoint4, mean); /* called standard deviation function with four data points and mean */
        printResults(dataPoint1, dataPoint2, dataPoint3, dataPoint4, mean, standardDeviation);  //called printResults functions to prints data points mean and standard deviation
        return 0;
}

Note : please replace "Your Name Here " with your name in code
Please upvote if you like answer otherwise comment for clarificaton.