( Latest Revision: 11/25/2012 )

SIXTH CS 1500 SOLO PROGRAM: Statistics Calculating Program


OBJECTIVE: The purpose of this programming assignment is to get practice using files, arrays, and loops.


ASSIGNMENT SYNOPSIS:

Write a program that reads some numbers from a file and calculates some statistics.


DETAILS:

For many of the details of the directions regarding this assignment, see the program shell. The program shell contains a finished main function. Your assignment is to carefully read the comments that describe what the other functions in the program are supposed to do, and then to write the code for those functions. I expect you to write the functions one at a time and test the program using appropriate stub code after writing each function. There is a file containing an extended terminal session that shows how the finished program is supposed to behave in various test situations.


INPUT:

You must write the program with certain facts, assumptions, and preconditions in mind:
THE DESIGN OF THE PROGRAM:

For this assignment I am requiring you to use the shell program I am giving you. You are required to add code implementing the functions, to make the program work correctly, and then to turn the program in like that - a program derived from my shell by inserting code to implement all the functions - no more and no less. In particular, you are not allowed to change anything in the program other than to add code for the functions. You have to leave the main function the way it is. You can't add any new functions or take out any functions. You can't add parameters to functions or take any away, or change a value parameter to a reference parameter, or vice-versa. You can't add global constants or variables, or take away any of the global constants. I expect you to employ good principles of top-down design when you develop the program.

I want you to have the experience of writing a program that reads from a file and uses an array. Therefore it is extremely important that you do not make any modifications in an attempt to avoid using a file or an array.

Because I am going to test all the programs by compiling and running them on different versions of the input file, I need everyone in the class to use exactly the same name for the input file. Therefore, please name your input file numbers.txt and make sure that your getData function reads the input from that file. If you don't change the header of getData, and you use the command:
ifstream fin(fname) ;
in your getData function, that will declare an ifstream named fin, and it will open the numbers.txt file.

Note: Depending on the computing environment in which you develop the program, you may not understand how to give a file the name numbers.txt. If you ask about it, I think I or Julie Gorman can help you figure it out.

Note: Come to class to get more discussion of how to design the code for the functions.


FORM AND FORMATTING REQUIREMENTS:

At the beginning of your program file put a header comment like this:

  /* PROGRAM: Stats Calculator */

  /*

  Name:          Gordon Goodguy
  User Name:     goodge
  Course:        CS 1500, Computer Programming I
  Instructor:    John Sarraille
  Date:          January 01, 1970

  */
Of course, in place of "Gordon Goodguy," you must put your own full name. In place of "goodge" put your user (login) name. In place of the Unix epoch, "January 01, 1970," put the date that you finished the program. Note that the comment delimiters /* and */ are important. They need to be placed correctly or you will get compiler errors.


TESTING:

When you make your test script, include all the tests that are in the extended terminal session. Also perform two more tests - where the number of integers in the file is one, and where the number of integers in the file is two.

To make it easier for me to check your work on the script, order your tests so that as you perform them, the number of items in the test files gets larger and larger. Also, put the 'unable to open file' test last. (That's the way I ordered my tests in the extended terminal session.)

The extended terminal session also illustrates a way to work with multiple versions of the input file, while still having just one name for the input file. Different versions of the input file have names like numbers000, numbers005, numbers050, numbers100, and numbers101. When we want to use one of the files for input, say numbers050, we do this unix command first:
cp numbers050 numbers.txt
The cp command is the unix command that makes a copy of a file. So after that command executes, numbers.txt is a copy of numbers050. So if we run the program right away after that, the program reads from numbers.txt, which is the same as numbers050. By doing a cp command before each program run, we can test many different input files, although the program always uses numbers.txt as the name of its input file.

When you do your testing, verify that all the output of the program is correct. You can use this web site to check calculations of averages and population standard deviations.


WHAT TO TURN IN:

You will be sending me two e-mail messages. Please follow these rules: Here is the list of things you have to turn in: Note that there are no spaces in the subject lines given. It is important that you do not insert any spaces. My e-mail address is:

john@ishi.csustan.edu



WHEN IS THIS ASSIGNMENT DUE?

Look for the due date in the class schedule. (It's at the top level of the class directory.)