Here are the new partnerships. The course webpage has a section on expectations for working with partners.
Both you and your partner should:
cd ~/cs31/labs
git clone [your_Lab04_URL]
Makefile grades.c grades1.txt readfile.c QUESTIONNAIRE grades0.txt grades2.txt readfile.hFor more detailed instructions see the the Using git guide.
Educators sometimes want a statistical analysis of a set of exam scores. These analyses could be done for an exam from a single class or an exam from an entire school district. A useful tool would be a program that computes statistical results for any size data set (i.e. it would work for ten values or for thousands, without re-compilation).
We will implement such a program this week. The program should take as a command-line argument the name of a file that contains a bunch of floats, one per line. The program then stores these values, computes a bunch of statistics about them, and prints the result to the user.
The starting point code comes with three input files that you can use to test your solution.
This program needs the readfile library and the math library. We have given you a Makefile that links in these libraries, so you should use the Makefile to compile. By reading the Makefile, you can see how the executable is built from a .c file and a .o file. The -lm flag tells gcc to link in the math library.
grades.c has the starting point code for your program. It contains a prototype for the get_values function that you need to implement, and it has some code in main that copies the file name given at the command line into a string local variable.
Your program should do the following:
get_values returns an array of float values initialized to the values read in from the file, or returns NULL on error (like if malloc fails or if the file cannot be opened). It dynamically allocates the array it returns and uses a doubling re-allocation algorithm if it runs out of space (see the requirements section for details about this algorithm).
Each histogram bucket counts the number of exam scores in a particular range: 0-9, 10-19, 20-29, etc. Exam grades that have a fractional component (e.g. 89.75) should be counted as being in a histogram bucket range based on their whole number part only (e.g. 89.75 is a grade in the 80's not a grade in the 90's).
Where is the number of values, is the value, and
is the mean (average) value.
Here is sample output from a working program run on the three input files that were included with the starting point code. You should also test your program on other input files that you create.
There are other ways to do this type of alloc and re-alloc in C. However, you should use this method.
double sqrt(double val);
This is not required, so don't attempt this challenge until you have finished all other parts of this lab.
There is a QUESTIONNAIRE file for you to fill out and submit with your lab solution. Your answers to the questionnaire will not affect your grade.
Only one member of your partnership needs to git push your solution before the deadline.