Question: When dealing with large groups of numbers, it is often statistically relevant to find out the median, mean and mode of the data set. Whether
When dealing with large groups of numbers, it is often statistically relevant to find out the median, mean and mode of the data set. Whether this data represents grades, temperatures or other observations of the world around us, finding these pieces of data can help us eliminate outlying data and concentrate on the more important results. For this program, you will create multiple files that will allow the program to read in a selection of data points and generate the required information. The format of the file is described in detail below. The files you will create will include:
please show the Statistics.h, Statistics.cpp, StatisticsDriver.cpp separately and use the basic sort .h and .cpp files and the .txt file provided
BasicSort.h
#if !defined BASIC_SORT_H
#define BASIC_SORT_H //Pre : array is an unsorted array of integers of size sz //Post : array is modified in place to be in sorted order in // : ascending order void insertionSort (int* array, int sz); #endif
BasicSort.cpp
#include "BasicSort.h"
using namespace std;
void insertionSort (int* array, int sz)
{
int curr;
int swap;
for (int i = 1; i < sz; i++)
{
swap = array[i];
curr = i;
while ((curr > 0) && (array[curr - 1] > swap))
{
array[curr] = array[curr - 1];
curr--;
}
array[curr] = swap;
}
}
Numbers20.txt
20,85,25,93,86,77,92,47,33,81,48,38,89,45,78,58,81,59,64,47,78
Statistics.h
Statistics.h will include an include guard and the functional prototypes required to calculate the information required by this program. Namely:
int* readData (const char* filename, int& size);
float findMean (int* numbers, int size);
float findMedian (int* numbers, int size);
int findMode (int* numbers, int size);
void displayInformation (float mean, float median, int mode);
Statistics.cpp
Statistics.cpp will contain all of the code necessary to implement the functions that are prototyped in Statistics.h
StatisticsDriver.cpp
StatisticsDriver.cpp will read in a filename from the user via command line arguments, then use the functions from Statistics.h/.cpp to create the necessary data structures, find the necessary information and display the results.
Input
The user will provide the file name containing all information via command line argument at the time the program is executed. If the file does not exist, the user should be prompted for a new file. The input fill I will provide (numbers20.txt) and all test files I use will follow the same formatting. The first line of the file contains the number of integer values in the file, after that line, the numbers are listed one per line. After all of the information has been read in, the functions outlined in Statistics.h should be run to get the required data and finally the information should be displayed in a nicely formatted table to the user.
Sample Output
Welcome to the statistics program. The statistics for the 20 read in values are : The mean of the data set provided is : 65.2 The median of the data set provided is : 70.5 The mode of the data set provided is : 47 Thank you and have a nice day
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
