The Tower of Babel

COBOL Example

Average Salary

PROCEDURE DIVISION.

BEGIN.
    OPEN INPUT EMPLOYEE-FILE, OUTPUT RESULT.
    MOVE ZERO TO SUM.
    MOVE ZERO TO EMPLOYEES.

AVERAGE.
    READ EMPLOYEE-FILE AT END GO TO DONE.
    ADD 1 TO EMPLOYEES.
    ADD HOURLY-RATE TO SUM.
    GO TO AVERAGE.

DONE.
    DIVIDE SUM BY EMPLOYEES GIVING AVERAGE.
    WRITE AVERAGE-LINE.
    CLOSE EMPLOYEE-FILE, RESULT.
    STOP RUN.


[TOC][Next]


CS1104 Main Page
Last Updated 01/05/2000
© L.Heath, 2000