School of Engineering and Applied Science
Department of Computer Science
CSci 49 -- Introduction to C Computing
http://www.seas.gwu.edu/~csci49/spring06
Prof. Michael B. Feldman 
mfeldman@gwu.edu


Project 9
Due Date: start of class, Thursday, April 27, 2006
FINAL DEADLINE FOR ALL PROJECTS! NO projects can be accepted after this date.

The goal of this project is to develop some functions that work with arrays, and to use them in an application program.

Project:

In this project you will write some functions to do simple statistical operations on a partially-filled array of integer data.

Part 1:

Copy and compile the file SimpleStats.c using ccheck; you will see that most of the functions are stubbed out; in this part of the project you will complete the stubbed methods. Test your methods using a simple test program; instead of bothering to read the data interactively, your test program can "hard-wire" the data just by initializing an array and sending it to the functions.

None of these functions write any output to the console. In each case, numbers is the partially-filled array that holds the integer values and howMany indicates how many values are present. The file also contains selectionSort, which is fully coded and can be used by other methods (like median).

/*------------------------------------------------------------
| Returns smallest value in array
------------------------------------------------------------*/
int minimum (int numbers[], int howMany)

/*------------------------------------------------------------
| Returns largest value in array
------------------------------------------------------------*/
int maximum (int numbers[], int howMany)

/*------------------------------------------------------------
| Returns average of values in array
------------------------------------------------------------*/
double average (int numbers[], int howMany)

/*------------------------------------------------------------
| Returns median of values in array
| If howMany is odd, returns middle value;
| if howMany is even, returns average of two middle values
------------------------------------------------------------*/
double median (int numbers[], int howMany)

/*------------------------------------------------------------
|  selection sort
------------------------------------------------------------*/
void selectionSort (int numbers[], int howMany)


Part 2:

In this part of the project, you'll build a menu-driven application that uses these functions (but also does more than the functions provide). The menu selections will be

R - read up to 12 integers from project9.dat into an array in the main program
P - display the contents of the array on the screen
M - compute and display the minimum value
X - compute and display the maximum value
V - compute and display the average value
D - compute and display the median value
Q - quit

As a starting point, copy, compile, and run the simple user-interface file SimpleUI.c. This is partially coded; you can modify it to meet this project's requirements. The data will be stored in the file with one number per line; the first value will indicate the number of data values in the file. This way you can use a count-controlled loop to read the data. Note that there is no function for readingthe data -- just code this in the appropriate section of the main switch statement in the UI.

What to submit

Follow the usual process. No framework bonus this time.

MBF 4/17/06