Question: Create a C++ header and implementation file named stats.h and stats.cpp. Your stats.h file must declare the functions listed below. You must also write comments
Create a C++ header and implementation file named stats.h and stats.cpp. Your stats.h file must declare the functions listed below. You must also write comments that indicate what the function does along with pre and post conditions just above each function declaration (i.e., add comments corresponding to what we put in the documentation strings when using Python). Your pre/post conditions must be more detailed than the minimal descriptions below that I included just so you know what each function should do. Your median function may sort the array as long as you document it. Include the #ifndef, #define, #endif statements in your header file. // returns average of numbers double mean (double nums[ ], int n); // returns median of numbers double median (double nums[ ], int n); // returns standard deviation of numbers double standardDeviation (double nums[ ], int n); // returns minimum of numbers double min (double nums[ ], int n); // returns maximum of numbers double max (double num [ ], int n) Your stats.cpp file must implement those methods. Note that you need to sort the array to determine the median. You may use the selection sort code from our book or for 5 bonus points write a C++ version of the merge sort. See chapter 1 of the book for the standard deviation formula. You may assume that no more than 10,000 numbers will be entered. Create a file named main.cpp with a main function that works as the following output shows. The first number entered indicates the number of values the user will then be entering. Enter number of values : 5 Enter number 1: 95 Enter number 2: 92 Enter number 3: 100 Enter number 4: 86 Enter number 5: 90 median: 92 mean: 92.6 standard deviation: 5.27257 min: 86 max: 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
