Write a program that calculates the mean and standard deviation of a collection
ID: 3652795 • Letter: W
Question
Write a program that calculates the mean and standard deviation of a collection of numbers. 1) Write a function, meanValue that will compute and return the average of the values in a 1-dimensional array. meanValue takes two arguments: a 1-dimensional double array and an integer representing the number of valid elements in the array. 2) Write a second function, stdDev that takes two arguments and returns the Standard Deviation of the values in the array. stdDev should call the meanValue function to determine the mean. 3) From main(), obtain a file name from the user for a file containing a collection of floating-point values. Declare a 1000 element 1-dimensional double array and read the values from the file into the elements of the array starting with the first.Explanation / Answer
#include #include #include #include using namespace std; double meanValue(double[], int); double stdDev(double[],int); int main(){ ifstream input; double data[1000]; int count=0; double StdDev, Mean; string filename; coutfilename; input.open(filename); if(input.is_open()){ while((!input.eof()) && (count>data[count]; count++; } Mean=meanValue(data,count); StdDev=stdDev(data,count); coutRelated 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.