Homework #6

Due 2 May, 1997, 5:00 PM

Complete Problem IV-18 on page 593 of the textbook.

The particulars

Create a protected directory called ~/csci/241/home6 as described in the handout Turning in Assignments. In solving this assignment, create three different Cobol programs and store them in the following files

home6.cob
the main program
tablea.cob
generates the table described in part (a) of the textbook's description
tableb.cob
generates the table described in part (b)

Design these programs to communicate via shared external records.

The input file for this problem is

COBOL tricks

You'll have to break the COBOL standard to complete this assignment. Here is a list (probably incomplete) of a few things you'll need to do.

Makefile

You'll need a different Makefile that will separately compile the three COBOL program files. Something like the following should work fine.

all:    home6 

home6:          home6.o tablea.o tableb.o
        cobol -o home6 home6.o tablea.o tableb.o

home6.o:        home6.cob
        cobol -c home6.cob

tablea.o:       tablea.cob
        cobol -c tablea.cob

tableb.o:       tableb.cob
        cobol -c tableb.cob

clean:
        rm -f home6 *.o HOME6.OUT

External records

You'll need to "tell" the COBOL compiler that the tables are being shared between the three files. This isn't hard: all you need to do is add the word EXTERNAL to the 01-level record definition of your program. Your definition should look something like:

01 CURRENT-PAYMENTS-TOTAL-TABLE EXTERNAL.
    05 CURRENT-PAYMENT-TOTAL    PIC 999999V99  OCCURS 6 TIMES.

Be sure that the identical record declaration appears in all COBOL programs that use the shared record.

The subroutine programs

When the non-main programs, in this case tablea.cob and tableb.cob, are called, execution begins with the first paragraph of the PROCEDURE DIVISION. In order to prevent COBOL from executing all paragraphs of your program, you must end the first paragraph with the statement EXIT PROGRAM. This repaces the STOP RUN which is commonly used to terminate COBOL programs.

The "name" of your sub-programs are given in the PROGRAM-ID sentence. I suggest you use

      PROGRAM-ID. TABLEA.

in tablea.cob and

      PROGRAM-ID. TABLEB.

in tableb.cob.

Meking the call

Use the non-standard CALL statement to execute paragraphs in the sub-programs. To call the first paragraph of table.cob include the statement

      CALL "TABLEA"

in your program. Yes, the quote marks are required.


Back to the homework index
Back to the CSCI 241 home page