Note: all of the following data files can be found in
the ~sgomori/students/cis314 directory.
Write a COBOL program named lab8sub.cob
that will be a subprogram (meaning it will be called from another program). It
will use 3 parameters, two input and one output. The program will accept a
dollar amount (PIC 9(9)V99) and a count (PIC 9(4)) and will return the average
(the dollar amount divided by the count, also PIC 9(9)V99). That's it.
Copy your lab4b program, the single-level
control break, to a new program named lab8a.cob. Modify this program so
that anytime it needs to calculate an average (per hospital or for UHOH) it
calls the subprogram to calculate it.
The input file is named lab8ain.dat
and your output file will be named lab8aout.dat. lab8ain is a copy of
the file used for lab 4, so it has the same format you used in that lab. The
output should be the same as that lab, also.
Makefiles are a UNIX thing, not a COBOL
thing. It's kind of like a script, it contains UNIX commands and will run them
in the specified sequence. For example, consider a file named makefile.
It contains:
lab5: ccbl lab5ap1.cob runcbl lab5ap1 ccbl lab5ap2.cob runcbl lab5ap2 ccbl lab5ap3.cob runcbl lab5ap3 ccbl lab5c.cob runcbl lab5ac clean: rm -f *.acu lab5*.dat cp /usr/class/cis314/lab5*in.dat .
It contains 2 sections, 'lab5' and
'clean'. Section names start in column 1 and end with a colon. The colon is immediately
followed by a carriage return. Each section contains UNIX commands. Anything
that can entered at the UNIX command prompt can be in the makefile. Each
command is preceded by a tab (not a few spaces, it must be a tab) and is
immediately followed by a carriage return. Makefiles are unforgiving
when it comes to whitespace.
At the command line, if one enters 'make
clean' then the two commands in that section are executed. First, any
executables are deleted, as are any .dat files for lab 5. The '-f' switch
prevents the rm command from asking for confirmation before deleting
each file, it just does it. The second command will copy a file to the current
directory and keep the same name (the space and period at the end of the
command).
'make lab5' at the command line will
compile and execute the 4 programs specified.
For your lab you will have to create a
makefile (the name must be makefile). It's just text, so whatever editor
you've been using for creating your COBOL source code will do fine here. The
makefile will have 3 sections:
The files to submit are:
Use the clean utility described in Lab 2.