Computer Science 1511
Computer Science I

Programming Assignment 3
Arithmetic and Procedures (35 points)
Due Thursday, October 14, 1998

Introduction

This assignment will involve reading data from the keyboard, performing arithmetic operations on it, and printing formatted results on the screen. Your program will be structured into functions. Since your program will be heavily modularized, be sure to test each function individually as you progress.

The Problem

You will write a program to read in scores for four students (Ann, Bob, Cris, and Doug) for three exams and you will print out a report showing the scores plus other information as shown below. Your program will first explain what the program does, prompt the user for scores, calculate the appropriate information, and then print out the report.

                                      Ann   Bob   Cris  Doug
Enter the four scores for exam 1 -->  195   212   195   178
Enter the four scores for exam 2 -->  215   220   235   190
Enter the four scores for exam 3 -->  210   190   210   206

                             Grade Report
                             ************

Student  |  Exam1  |  Exam2  |  Exam3  |  Total  |  Average  |
--------------------------------------------------------------
A        |   195   |   215   |   210   |   620   |   206.7   |
B        |   212   |   220   |   190   |   622   |   207.3   |
C        |   195   |   235   |   210   |   640   |   213.3   |
D        |   178   |   190   |   206   |   574   |   191.3   |
--------------------------------------------------------------
Total    |   780   |   860   |   816   |  2456   |   818.7   |
--------------------------------------------------------------
Average  |   195.0 |   215.0 |   204.0 |   614.0 |   204.7   |
--------------------------------------------------------------

                      Hope Everyone Gets an A!!!

Note that you will need to add output explaining what the program does.

NOTE (10/7/99) - you need not print out all of the students name in the Grade Report. You can simply print out an A for Ann, B for Bob, etc.

Program Structure

Your main function must consist of declarations and function calls only. Following is an outline of a main function you can use (if you are not going to use exactly this main function you should plan on using something similar). Your job is to provide the declaration part of the program and also the parameters for those procedure calls which require them.

  int main () {
    /* Needed variables */

    Welcome();		/* Prints instructions */

    GetScores( ... );	/* Get exam 1 scores */
    GetScores( ... );	/* Get exam 2 scores */
    GetScores( ... );	/* Get exam 3 scores */
 
    exam1_total = CalcExamTotal( ... );	/* Total scores for exam 1 */
    exam2_total = CalcExamTotal( ... );	/* Total scores for exam 2 */
    exam3_total = CalcExamTotal( ... );	/* Total scores for exam 3 */

    exam1_avg = CalcExamAvg( ... );	/* Calc exam1 average */
    exam2_avg = CalcExamAvg( ... );	/* Calc exam2 average */
    exam3_avg = CalcExamAvg( ... );	/* Calc exam3 average */

    ann_total = CalcStudentTot( ... );	/* Total scores for Ann */
    bob_total = CalcStudentTot( ... );	/* Total scores for Bob */
    cris_total = CalcStudentTot( ... );	/* Total scores for Cris */
    doug_total = CalcStudentTot( ... );	/* Total scores for Doug */
 
    ann_avg = CalcStudentAvg( ... );	/* Calc Ann's average */
    bob_avg = CalcStudentAvg( ... );	/* Calc Bob's average */
    cris_avg = CalcStudentAvg( ... );	/* Calc Cris's average */
    doug_avg = CalcStudentAvg( ... );	/* Calc Doug's average */

    PrintHeading();

    PrintStudentLine( ... );	/* Print Ann's info */
    PrintStudentLine( ... );	/* Print Bob's info */
    PrintStudentLine( ... );	/* Print Cris's info */
    PrintStudentLine( ... );	/* Print Doug's info */
 
    printExamTotals( ... );	/* Prints exam totals line */

    printExamAverages( ... );	/* Prints exam averages line */

    fflush(stdin);
    printf("Press return to finish.");
    getchar();
    return 0;  /* Changed - 10/7/99 */
  }

Your TA will discuss with you how each of these routines should work.

What To Hand In

Consult the Programming Assignment Guidelines for information on what to put in the report to go with this program. Note in your structure chart which boxes correspond to functions in your program. Make sure that your test output shows that your program produces output exactly like that given above. You should also include other samples of your program running (on different data values to demonstrate that it works).