# Homework 7

CS17

80 pts., due May 10

For each program, you should turn in the source code and a print-out showing a sample run (print the output window). Follow the guidelines in Section 3.7 for the style of your programs. In addition:

1. Use descriptive names for variables and named constants. In addition, write a brief comment for each variable and named constant describing how it is used.
2. Use uppercase characters for named constants with underscores to separate ``words.'' Use lowercase characters for variables with either underscores or capitalization to separate ``words.''
3. If a formula you use in a statement isn't obvious, comment it. In general, comment any non-obvious statement or statement block.
4. Your program should be modular (i.e., use several functions). No function should be longer than a single page.

Design and implement a simple statistics package. Your program will do the following:

1. Query the user for the name of a disk file to open for reading, and open the file (repeat until a file is opened). Use the compiler to make your data file. Name the file grades.txt.
2. Data in the file will consist of grades, one per line. Read the grades from the file into an int array, keeping track of the number of grades. There will be at most 100 grades (Use a symbolic constant!).
4. Sort the grades into ascending order.
5. Compute and print the following information:
• The median grade. (The middle grade from the array of sorted grades. If there is no one middle grade, i.e., the number of grades is even, then average the two ``middle'' grades and call the average the median.)
• The number of A's, B's, C's, D's, and F's.
• The standard deviation. Here's the formula:

6. Query the user for the name of a disk file to open for writing, and open the file (repeat until a file is opened). Use the name sorted.txt.
7. Write the sorted grades from the array to the output file. Close the output file when finished writing grades. After the file has been written, you can use the compiler to open and examine the file.

Hand-in your source code, the output from running the program, and copies of the input and output files.

Thomas P. Kelliher
Wed May 1 08:57:03 EDT 1996
Tom Kelliher