Write a C++ program to get input of a data set of 14 double values (grades) from
ID: 3938768 • Letter: W
Question
Write a C++ program to get input of a data set of 14 double values (grades) from the standard input device (the keyboard), then calculate and report the sum and the mean of the data set, then the individual DEVIATION of each individual input with respect to the mean, the variance of the dataset, and finally the standard deviation of the data set. This problem requires you to integerate multiple things together: arrays, loops, functions. More specifically, you want to use loops to deal with input, save them to array, or calculate sum and individual deviation, and display results etc. in separate functions.A sample run.
Please let me know how many grades you would like to input? 14 Input them one by one: 89 95 72 83 99 54 86 75 92 73 79 75 82 73.
Enter a grade: 89
Enter a grade: 95
Enter a grade: 72
Enter a grade: 83
Enter a grade: 99
Enter a grade: 54
Enter a grade: 86
Enter a grade: 75
Enter a grade: 92
Enter a grade: 73
Enter a grade: 79
Enter a grade: 75
Enter a grade: 82
Enter a grade: 73
The sum is: a number here.
The mean is: 80.5
GRADE INDIVIDUAL DEVIATION
89 8.5
95 14.5
72 -8.5
83 2.5
99 18.5
54 -26.5
86 5.5
75 -5.5
92 11.5
73 -7.5
79 -1.5
75 -5.5
82 1.5
73 -7.5
The variance is: 124.679 standard deviation: 11.166
Write a C++ program to get input of a data set of 14 double values (grades) from the standard input device (the keyboard), then calculate and report the sum and the mean of the data set, then the individual DEVIATION of each individual input with respect to the mean, the variance of the dataset, and finally the standard deviation of the data set. This problem requires you to integerate multiple things together: arrays, loops, functions. More specifically, you want to use loops to deal with input, save them to array, or calculate sum and individual deviation, and display results etc. in separate functions.
A sample run.
Please let me know how many grades you would like to input? 14 Input them one by one: 89 95 72 83 99 54 86 75 92 73 79 75 82 73.
Enter a grade: 89
Enter a grade: 95
Enter a grade: 72
Enter a grade: 83
Enter a grade: 99
Enter a grade: 54
Enter a grade: 86
Enter a grade: 75
Enter a grade: 92
Enter a grade: 73
Enter a grade: 79
Enter a grade: 75
Enter a grade: 82
Enter a grade: 73
The sum is: a number here.
The mean is: 80.5
GRADE INDIVIDUAL DEVIATION
89 8.5
95 14.5
72 -8.5
83 2.5
99 18.5
54 -26.5
86 5.5
75 -5.5
92 11.5
73 -7.5
79 -1.5
75 -5.5
82 1.5
73 -7.5
The variance is: 124.679 standard deviation: 11.166
Write a C++ program to get input of a data set of 14 double values (grades) from the standard input device (the keyboard), then calculate and report the sum and the mean of the data set, then the individual DEVIATION of each individual input with respect to the mean, the variance of the dataset, and finally the standard deviation of the data set. This problem requires you to integerate multiple things together: arrays, loops, functions. More specifically, you want to use loops to deal with input, save them to array, or calculate sum and individual deviation, and display results etc. in separate functions.
A sample run.
Please let me know how many grades you would like to input? 14 Input them one by one: 89 95 72 83 99 54 86 75 92 73 79 75 82 73.
Enter a grade: 89
Enter a grade: 95
Enter a grade: 72
Enter a grade: 83
Enter a grade: 99
Enter a grade: 54
Enter a grade: 86
Enter a grade: 75
Enter a grade: 92
Enter a grade: 73
Enter a grade: 79
Enter a grade: 75
Enter a grade: 82
Enter a grade: 73
The sum is: a number here.
The mean is: 80.5
GRADE INDIVIDUAL DEVIATION
89 8.5
95 14.5
72 -8.5
83 2.5
99 18.5
54 -26.5
86 5.5
75 -5.5
92 11.5
73 -7.5
79 -1.5
75 -5.5
82 1.5
73 -7.5
The variance is: 124.679 standard deviation: 11.166
Explanation / Answer
Edit & Run
#include <iostream> #include "vector.h" //link to vector.h file (no changes since lab03) using namespace std; int main() { //Function for average double avg ( vector& v ) { double return_value = 0.0; int n = v.size(); for ( int i=0; i < n; i++) { return_value += v[i]; } return ( return_value / size); } //****************End of average funtion**************** //Function for variance double variance ( vector& v , double mean ) { double sum = 0.0; double temp =0.0; double var =0.0; for ( int j =0; j <= v-1; j++) { temp = pow(v[j] - mean),2); sum += temp; } return var = sum/(v.size() -2); } //****************End of variance funtion**************** //****************main from lab03**************** vector<float> v; //creates vector of floats v.size(100); //size 100 vector of floats //Get input from user cout << "Please input any number: " << endl; for (float i=0; getFloat() != ' '; i++) { cin >> v[i]; } //****************end of main from lab03**************** } Edit & Run
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.