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

C ++ PROBLEM A simialr problem was on the system is not coded correclty for the

ID: 3561330 • Letter: C

Question

C ++ PROBLEM A simialr problem was on the system is not coded correclty for the assignment.
The mean (average) and standard deviation calculator allows the user to enter the name of a class
and 10 scores. The calculator then displays a message as follows:

SummerCS115test1: mean = 75.7 and standard deviation = 9.3

The word SummerCS115test1 is replaced by the name entered and 75.7 and 9.3 are replaced by
the numbers calculated by the program. Use C++ functions to display the numbers to one
decimal place. The scores should be of either type float or double.Do not use array or calsses.
The mean is just a result of dividing the sum of scores by 10. In mathematical notation, the sum
is represented by the Greek letter capital sigma. Let n = 10. Each score is written as xi. Where
i is a variable that takes the places of the score number so that i=1 for the first score, i=2 for the
second and so on.

The standard deviation is square root of a result of the sum of squares of differences between
scores and the mean divided by n

Explanation / Answer

#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
   cout << "Enter the name of the class"<< endl;
   string name ="";
   cin >> name;
   cout << "Enter 10 values" << endl;


   float sum =0;
   int n = 10;
     float values[n] ;
   for(int i = 0; i < n; i++) {
       cin >> values[i];
       sum = sum+values[i];
   }

   //calculate mean
   float mean = sum/n;

   //calculate variance
    double temp = 0;

    for(int i = 0; i < n; i++)

    {

         temp += (values[i] - mean) * (values[i] - mean) ;

    }

    float variance = temp / n-1;
  
    //calculate standar deviation
    float sd = sqrt(variance);
  
    cout << name <<"   Mean: "<<mean << " Standard Deviation: "<< sd << endl;
      
   return 0;
}