SlideShare a Scribd company logo
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
Solution
Edit & Run
#include #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 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

More Related Content

PPT
ch02-primitive-data-definite-loops.ppt
PPT
ch02-primitive-data-definite-loops.ppt
PPTX
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...
PPTX
A S.O.L.I.D. Primer
PPT
Lecture#3 Algorithms and computing
PPTX
Introduction to Design and Analysis of Algorithms
PDF
The Basics of MATLAB
PPT
Ch02 primitive-data-definite-loops
ch02-primitive-data-definite-loops.ppt
ch02-primitive-data-definite-loops.ppt
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...
A S.O.L.I.D. Primer
Lecture#3 Algorithms and computing
Introduction to Design and Analysis of Algorithms
The Basics of MATLAB
Ch02 primitive-data-definite-loops

Similar to Write a C++ program to get input of a data set of 14 double valu.pdf (15)

PPT
Standard deviation
PPT
JavaHTP7e_1313_DDP.ppt
PDF
04-Intro-SQL database management systems
PDF
Effective PHP. Part 5
PPTX
PPTX
Intro to programing with java-lecture 3
PPTX
Java basics-includes java classes, methods ,OOPs concepts
PPTX
Csci101 lect08b matlab_programs
PDF
CMIS 102 HANDS-ON LAB WEEK 6 OVERVIEW THIS HANDS-ON LAB ALLOWS YOU TO FOLLOW ...
DOCX
OverviewThis hands-on lab allows you to follow and experiment w.docx
PPTX
System Verilog 2009 & 2012 enhancements
PPTX
control statements of clangauge (ii unit)
PPT
03b loops
PPT
Copy of dti2143/dam31303 chap 1 problem solving and program design
Standard deviation
JavaHTP7e_1313_DDP.ppt
04-Intro-SQL database management systems
Effective PHP. Part 5
Intro to programing with java-lecture 3
Java basics-includes java classes, methods ,OOPs concepts
Csci101 lect08b matlab_programs
CMIS 102 HANDS-ON LAB WEEK 6 OVERVIEW THIS HANDS-ON LAB ALLOWS YOU TO FOLLOW ...
OverviewThis hands-on lab allows you to follow and experiment w.docx
System Verilog 2009 & 2012 enhancements
control statements of clangauge (ii unit)
03b loops
Copy of dti2143/dam31303 chap 1 problem solving and program design
Ad

More from arshiartpalace (20)

PDF
Which plants contain lignified vascular tissue (Select all that appl.pdf
PDF
Which of the neurotransmitters are metabotropic and which are ionotr.pdf
PDF
What is the range of y= absolute value f(x) if f(x) = -x^2 And can .pdf
PDF
G. Will a pumping test that is run for seven days give more informati.pdf
PDF
What challenges, strengths, or weaknesses do you see Baxter Internat.pdf
PDF
Three historical figures were identified as working with vita statist.pdf
PDF
What are postretirement benefits other than pensionsSolutionB.pdf
PDF
There are parts of a true sustained competitive advantage Ther.pdf
PDF
Frequency .java Word frequency counter package frequ.pdf
PDF
The alternative hypothesis typically Corresponds to the presumed def.pdf
PDF
Suppose the continuous random variable X has probability density func.pdf
PDF
Drag and drop the phrases to the appropriate status during the cockin.pdf
PDF
Some bacteria have one or more flagella. What is true about these st.pdf
PDF
our company has an opening for a junior database administrator. As a.pdf
PDF
Part ABriefly, explain the current hypotheses about how brown alg.pdf
PDF
Please show the whole code... Im very confused. Matlab code for ea.pdf
PDF
Monomeric single pass trans-membrane proteins generally span the bil.pdf
PDF
Match the following to one or more layers of the Internet protocol st.pdf
PDF
Kent and Emily have a baby boy Dustin by in vitro fertilization. Dust.pdf
PDF
Isabel Lopez started Biz Consulting, a new business, and completed th.pdf
Which plants contain lignified vascular tissue (Select all that appl.pdf
Which of the neurotransmitters are metabotropic and which are ionotr.pdf
What is the range of y= absolute value f(x) if f(x) = -x^2 And can .pdf
G. Will a pumping test that is run for seven days give more informati.pdf
What challenges, strengths, or weaknesses do you see Baxter Internat.pdf
Three historical figures were identified as working with vita statist.pdf
What are postretirement benefits other than pensionsSolutionB.pdf
There are parts of a true sustained competitive advantage Ther.pdf
Frequency .java Word frequency counter package frequ.pdf
The alternative hypothesis typically Corresponds to the presumed def.pdf
Suppose the continuous random variable X has probability density func.pdf
Drag and drop the phrases to the appropriate status during the cockin.pdf
Some bacteria have one or more flagella. What is true about these st.pdf
our company has an opening for a junior database administrator. As a.pdf
Part ABriefly, explain the current hypotheses about how brown alg.pdf
Please show the whole code... Im very confused. Matlab code for ea.pdf
Monomeric single pass trans-membrane proteins generally span the bil.pdf
Match the following to one or more layers of the Internet protocol st.pdf
Kent and Emily have a baby boy Dustin by in vitro fertilization. Dust.pdf
Isabel Lopez started Biz Consulting, a new business, and completed th.pdf
Ad

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
01-Introduction-to-Information-Management.pdf
PDF
Classroom Observation Tools for Teachers
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Complications of Minimal Access Surgery at WLH
human mycosis Human fungal infections are called human mycosis..pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Anesthesia in Laparoscopic Surgery in India
O7-L3 Supply Chain Operations - ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
VCE English Exam - Section C Student Revision Booklet
01-Introduction-to-Information-Management.pdf
Classroom Observation Tools for Teachers
STATICS OF THE RIGID BODIES Hibbelers.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
RMMM.pdf make it easy to upload and study

Write a C++ program to get input of a data set of 14 double valu.pdf

  • 1. 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
  • 2. 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
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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.
  • 8. 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
  • 9. 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
  • 10. 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 Solution Edit & Run
  • 11. #include #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 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