IUP Computer Science
COSC 110    Spring 2002
 
 

Project #6
Due 1 May 2002


The Communications Media Department at Whatsamatta University has recently conducted a survey of the television watching habits of the students on their campus.  The survey has two goals  1) to determine whether there is a relationship between a student's age and the programs that the student watches  and 2) to determine whether there is a relationship between a student's grade point average and the programs that the student watches.  Actually, a bit of extra information was collected from each student to provide for additional studies later.

Exactly 500 student interviews were conducted with the information being placed in a file named TVWatching.txt  Each line of this file contains a student ID number, seven TV channel numbers, the student's age, grade point average (GPA), number of credits being carried, and a 3- or 4-letter designator of the student's major.  The seven TV channel numbers are what the student reports s/he was watching at 9 pm on each night during the survey week (Sunday through Saturday).  Whatsamatta U. provides only basic cable to its students; consequently, all channel numbers reported in the survey are between 2 and 13, with 0 being reported for "not watching TV."  Also, only traditional college students were surveyed; thus, the ages are limited to between 18 and 23 years old.

Because controls were rather lax during the taking of the survey, a few students were interviewed two or more times.  Such students must not have their interview reports counted at all because they might skew the results.  There is no particular order to the interviews in the file.

You are to write a C++ program that reads the TVWatching.txt file and produces a report of the numbers of students by age that are watching each channel at 9 pm for whatever night of the week the person running the program selects.  That is, the program should prompt for a day name and expect the person at the keyboard to enter "Sunday, Monday, . . . or some other day" and then display a table showing the distribution of TV watching by age and channel for that night.  The program must also show an average GPA for each channel being watched.  Below is a sample of the output for Wednesday viewing from processing the only first 100 interviews from the file - your program must process all 500 interviews in the file.

Eliminated viewers:
131906

Which day? Wednesday

Channel Viewings for Wednesday   98 viewers
Ages     Channel Watched
         0    2    3    4    5    6    7    8    9   10   11   12   13  Total

 18      9    1    0    0    1    1    1    0    3    0    2    3    1   22
 19      8    0    2    2    1    1    2    0    1    0    2    0    1   20
 20      8    0    0    1    0    1    0    1    2    2    1    2    1   19
 21      5    0    0    2    1    0    0    0    1    1    2    0    2   14
 22      4    0    1    0    0    1    1    0    1    0    0    1    0    9
 23      8    1    1    0    0    1    1    0    0    0    1    1    0   14

Total   42    2    4    5    3    5    5    1    8    3    8    7    5

Average GPA by Channel Watched
     0     2     3     4     5     6     7     8     9    10    11    12    13
  2.85  3.38  2.51  3.07  3.31  2.78  3.25  2.45  3.05  2.61  2.50  3.12  2.90

As you can see, student 131906 appeared twice; so both of his/her entries were eliminated.  The remaining 98 viewer entries are counted in the age by channel table and in the GPA by channel listing.

Your program should be designed so that the person at the keyboard may enter any day of the week and get a listing for that day; then the program should prompt for another day.  When the person at the keyboard enters "Saturday", the program should display the results for that day and quit.

You can get your copy of TVWatching.txt from either the world-read folder under the course on the P: drive or from the jlwolfe\co110 folder on the I: drive.

Hand in a printout of your program and a printout of the complete results if the person at the keyboard inters Thursday as the day of the week.  Name your .cpp file after yourself (as in yourname.cpp) and copy it to the hand-in folder for the course on the P: drive.