CS 111 - SUMMER 2002: Homework 3

Due: Thursday, June 13

Reading: Chapter 4, pages 269-280, and Chapter 5, pages 304-343.


Reminder: Homework is due by 11:59 PM.

The files you must submit for this homework are exactly scores.cpp which contains your program, and scores.scr, a script file which contains a script session showing the program, its compilation, and its output on the test files. To do this you need to use the gsubmit program and remember to put the 2 files you want to submit into a directory called hw3 and gsubmit hw3 to the class cs111a2. There is a pointer to gsubmit information on the class home page.

Program:

Please write me a program which will help me with my grading. In this small class there are 3 homework assignments, each worth 100 points.

The input list has one student per line . On this line are the student's name and the grades the student received for the 3 assignments. So, for example, Smith 78 54 100.

The length of the list varies, though there are no more than 50 students and the name of each student has no more than 20 characters. The list will end with a line that looks like, End -1 -1 -1.

Your program should calculate the average grade and should store the name of each person and the average grade for each person. This information should be stored in 2 arrays of equal lengths, an array of names (so this is actually an array of arrays) and an array of corresponding average grades.

It should then print out a histogram of the number of grade averages in each 10 point interval. Note there are small gaps here between the intervals, for example 9-10 or 89-90. Any number in these gaps should be rounded down, so an average of 89.6 would fall into the 80-89 interval. So, for example,

0-9    |
10-19  |** 
20-29  |*
30-39  |******
40-49  |********
50-59  |***
60-69  |************
etc.

Your program should also calculate and print out,

1. the total number of students,

2. the average grade of the whole class on their three homeworks (that is the average if all the averages), and

3. the interval which has the most grades in it. (This is the interval 60-69 in the above example.) If there is more than one such interval, print them all.

4. The name of anyone who has the scores of 100 (that is an average of 100).

5. The name and average grade of the person, or people, who have the lowest average(s).

6. The person with the longest name. (All of them if more than 1.)

Your program should include functions to do the various tasks. Your main function should just call the other functions as needed. So there should be a function which computes the class average, one which finds the interval with the most grades, and another which prints the histogram and others. You should use an array of length 10 which stores the number of grades in each of the ten point intervals. Your function to find the interval with the most grades and your "histogram" function should take as argument a pointer to this array.

Your program should be well formatted and well commented. Variables should be reasonably named, etc. Take as your model the format and comments of the calendar program.

Make sure you test for bad data as the numbers are read in to your program. Two lists which you should run on are found in the files data1 and data2, or in the files ~homer/data3-1 and ~homer/data3-2 on csa. Also, as usual, try a few lists of your own creation. The files you should turn in should be named scores.cpp and scores.scr.


Academic Honesty and Collaboration

It is reasonable to discuss with others possible general approaches to problems. It is unreasonable to work together on a detailed solution, to copy a solution, or to give away a solution. If your common discussion can be detected by looking at the solutions, then there is too much collaboration. Such instances of academic dishonesty will result in a course grade of F or expulsion from Boston University.

Do not allow your work to be used by others:

Warning: If someone cheats by using your work, you will also be penalized


Page Created: May 25, 2002