Question: Program 3 : Mean, Median and Mode (top) C:CSC1300Programs> Statistics.exe numbers20.txt Welcome to the statistics program. The statistics for the 20 read in values are
Program 3 : Mean, Median and Mode
(top)
C:\CSC1300\Programs> Statistics.exe numbers20.txt 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
Objective
Learn to use Loops, Arrays and Pointers to build more complex programs
Using #include to include code provided by others
Practice working with functions and multiple files to build programs modularly
Concepts
Arrays
Functions
Pointers
Command Line Arguments
Header Files
Description
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:
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
A couple of quick notes...
A word about Mode
Since mode is the item that appears most often in your data set it is possible to have multiple modes within the same dataset. Your program should return the FIRST of the data points that occurs if a tie exists.
A further word about Mode (and Median)
While finding the mode and median of a list of data points IS possible with the list being unsorted, it is appreciably harder to do. With that in mind, you might want to use functions from the BasicSort.h/BasicSort.cpp files attached to sort the data.
Provided Files
Numbers20.txt BasicSort.h BasicSort.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
