Description Your task is to create a personal library to implement a statistic p
ID: 3681779 • Letter: D
Question
Description
Your task is to create a personal library to implement a statistic package on any given data (assume that the data is always of type float). To do this you must create:
1.a header file (stats.h) with 5 function prototypes:
maximum()
minimum()
mean() – equation:
variance() – equation:
histogram()
2.five (5) implementation files with each of functions listed above – min.c, max.c, mean.c, variance.c, and histogram.c
You will then write C code (lab4.c) that asks the user for the data file he/she wishes to compute the statistics for and displays the results to the user. YOU WILL NOT WRITE ANY STATISTICS FUNCTIONS IN lab4.c – you will simply call the functions prototyped in stats.h and coded in min.c, max.c, mean.c, variance.c, and histogram.c!!!
Procedure: (Refer to textbook pg 667-677)
1.Create the header file stats.h:
a.Start with a block comment summarizing the purpose of the header file
b.# define any constant that you need for the header file (NOT YOUR CODE)
c.Individual function prototypes (with introductory comments stating purpose of each function)
d.Save
e.Below is the template for stats.h
#ifndef STATS_H
#define STATS_H
float minimum(…); // NOTE: You need to complete the prototypes
float maximum(…);
float mean(…);
float variance(…);
void histogram(…);
#endif // STATS_H_INCLUDED
2.Create 5 implementation files (min.c, max.c, mean.c, variance.c, histogram.c
a.Start with a block comment summarizing the purpose of each implementation file
b.#include the necessary standard C libraries for each function
c.#include “stats.h”the angular brackets (< >) are used for standard C libraries found in the system directory, the quotation marks () indicate a custom library found in the SAME directory as your code.
d.any constants for that particular implementation file
e.Each file will contain one function as you would normally write it.
i.The first four files will calculate maximum, minimum, mean, and variance and return one value each time (so they can be regular call-by-value functions)
ii.Your histogram function will count the number of occurrences of data within a certain range; each range is commonly referred to as a “bin”. We will fix the number of bins that we use to ten. You will divide the range of your data (max-min) into 10 bins. Let’s assume that max = 100 and min = 0. The first bin will hold the number of data points between 0 and 9, the second will hold the number of data points between 10 and 19, etc. Note that the ranges for each bin are inclusive and that the last bin must have a range of 90 to 100 (not 90 to 99).
iii.Points will be lost for using 10 if-else statements!!! Think nested loops.
iv.Your histogram function must be passed the number of data points, a pointer to the data array, and a pointer to a 10 element array that will hold the histogram count.
f.Note: the implementation files WILL NOT have a function.
g.Note: the implementation files WILL NOT have ANY I/O functions (printf(), scanf() etc).
h.Make sure all these files are added to the project along with the header file.
3.Create your code (lab4.c)
a.Include the usual (detailed) comment block including program name, author, date, inputs, outputs and description.
b.Along with all the regular #include statements you MUST Remember use double quotes to indicate local header file.
c.Download the input test file from course website.
d.Create a function of type to explain the program to the user. Do not forget to call the function from .
e.Create a function to read the data from the file into your input array and call it from . This function will return the number of grades in the file. Assume that the maximum number of scores is 1000.
f.OUTPUT ALL RESULTS FROM . Your output must match the format example given below.
---------------------------------------------------------------------------------
Output format:
There are 400 grades read
Mean = 60.022750
Variance = 205.449531
Maximum = 100.000000
Minumum = 0.000000
Grade Histogram
0% - 9%: 2
10% - 19%: 1
20% - 29%: 4
30% - 39%: 24
40% - 49%: 59
50% - 59%: 105
60% - 69%: 108
70% - 79%: 67
80% - 89%: 24
90% - 100%: 6
The above printout implies that there were 2 scores between 0% and 9%, 1 score between 10% and 19%, 4 scores between 20% and 29%, etc. in the file “grades.txt”.