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

Please write a C++ code. Thank you so much. Write a program that takes as input

ID: 674331 • Letter: P

Question

Please write a C++ code. Thank you so much.

Write a program that takes as input five numbers and outputs the mean (average) and standard deviation of the numbers. If the numbers are X_1, X_2, X_3, X_4, and x_5, then the mean is x = (x1 + X_2 + X_3 + X_4 + x_5)/5 and the standard deviation is: s=squareroot (x1-x)^2+(x_2-x)^2+(x_3-x)^2+(x_4-x)^2+(x_5-x)^2/5 Your program must contain at least the following functions: a function that calculates and returns the mean and a function that calculates the standard deviation. Grading scheme: a function to calculate the mean - 5 points; a function to calculate the standard deviation - 5 points; a main function to call the two functions above correctly .

Explanation / Answer

#include <iostream>

#include <math.h>

using namespace std;

float calcMean(float x1, float x2, float x3, float x4, float x5) {

return (x1+x2+x3+x4+x5)/5.0;

}

float calcSD(float x1, float x2, float x3, float x4, float x5, float x) {

return sqrt((((x1-x)*(x1-x)) + ((x2-x)*(x2-x)) + ((x3-x)*(x3-x)) + ((x4-x)*(x4-x)) + ((x5-x)*(x5-x)))/5.0);

}

int main() {

float x1,x2,x3,x4,x5;

cout<<"Enter 5 numbers seperated by space: ";

cin>>x1>>x2>>x3>>x4>>x5;

  

cout<<" ";

float mean = calcMean(x1, x2, x3, x4, x5);

cout<<"Mean is: "<<mean<<" ";

cout<<"Standard Deviation is: "<<calcSD(x1, x2, x3, x4, x5, mean);

  

cout<<" ";

return 0;

}