CS 162 Fall 2001                                Assignment 1 – Review Introductory Programming                                                                      100 points

 

Assigned: 08/27/2001

Due: 09/04/2001 at the start of class.

Pre-Lab (Do Before Lab): Bring an empty (or nearly empty) disk. Plan out sequence of statements needed for program.

Pairs: You may work in pairs if you want. Note, during the course of the semester, you cannot pair with any one person more than twice. If you work in a pair, turn in ONE copy that is the work of both of you, with both of your names on it.  Each member of the pair will receive the same grade for that lab.  In such a partnership, students must share as equally as possible the work and learning.  Working together with truly shared effort and learning can be a positive experience. However, simply giving/receiving code from someone defeats the learning process. If substantial parts of a program are taken from non-partners, that is plagiarism. The copier and copyee will each receive a zero.

Main Assignment:

                The Center for The Media in the Public Interest has commissioned you to write a program to track the coverage of the Levy / Condit story by TV News. Perhaps, they believe that the stem cell research issue is perhaps a tad more important. Write a program that will ask the user for the number of weeks to track, then for each of NBC, ABC, CBS, and Fox, ask how many minutes were devoted to the Levy / Condit story each week. Finally, display summary info. Create an array of coverage for each of the networks. As always, divide the program into functions. You can assume that we will not track more than 100 weeks. You should validate input to ensure that the number of minutes entered is between 0 and 500 (inclusive).

Sample interaction with the user:

How many weeks are we tracking? 5

     

                Enter the number of minutes of coverage for NBC

                                Week 1:   12.5

                                Week 2:   45.4

                                Week 3:   3400

                                Please enter a value between 0 and 500:   34.0

                                Week 4:   56.9

                                Week 5:   40.1

                Enter the number of minutes of coverage for ABC

                                Week 1:   15.5

                                Week 2:   35.0

                                Week 3:   38.0

                                Week 4:   69.5

                                Week 5:   50.0

                Enter the number of minutes of coverage for CBS

                                Week 1:     2.5

                                Week 2:     0.0

                                Week 3:     3.0

                                Week 4:     4.5

                                Week 5:     0.0

                Enter the number of minutes of coverage for Fox

                                Week 1:     6.5

                                Week 2:   12.0

                                Week 3:   18.5

                                Week 4:   35.5

                                Week 5:   55.0

 

Center for Media in the Public Interest

Levy / Condit Coverage Study

 

      Week        NBC         ABC         CBS         Fox

      ====        ====        ====        ====        ====

        1         12.5        15.5        2.5        6.5

        2         45.4        35.0        0.0        12.0

        3         34.0        38.0        3.0        18.5

        4         56.9        69.5        4.5        35.5

        5         40.1        50.0        0.0        55.0

      ====        ====        ====        ====        ====

      Total      188.9      208.0       10.0       127.5

 

      Ave         37.8        41.6        2.0        25.5

 

      Overall Ave:  26.7

 

Hand-in:

     1) Listing of the program

     2) Disk with your .c file and your working .exe file. NAME YOUR PROGRAM FILE yourlastname1.c; Name your project yourlastname1 so that the executable will be yourlastname1.exe. If you are working in pairs, use both last names (e.g. redmondsmith1.c)

Miscellaneous:

1) Make your program work like shown above. If you have any questions about what should be done, please ask!!

2) MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). Test it more than once - I will! Your program needs to be able to handle any inputs including catching invalid inputs.

3) Remember: Indentation, meaningful variable names, symbolic constants, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit. Also make sure you put YOUR NAME(s), section, and e-mail address in comments at the beginning of the program.