We are again dealing with the skippers of 8 fishing boats. This time they are not in a competition. Each boat has made 5 trips to each of 6 bays to catch fish of 3 different kinds. From time to time, the skippers or their employers need information about the results of these trips.
Your task is as follows:
Input Files
The records in the first file have the following format:
Boat-Name 20 characters
Bay-Name 10 characters
a table of 5 entries, each containing
Tuna 3 digits (packed decimal)
Moonfish 3 digits (packed decimal)
Scad 3 digits (packed decimal)
The data has been sorted by boat and by bay, in that order.
The query records have the following format:
Query-Code 1 character
Boat-Name 20 characters
Bay-Name 10 characters
Trip-Number 1 digit (binary)
Fish-Name 8 characters
Any of the names may be left blank, or Trip-Number may be 0. The values indicate where to look in the table for the data to process. If a field is left blank, or if Trip-Number is 0, then we want to use all entries with any value of that field.
Query-Code may be 'S' if what we want is the sum of the weights of fish in all matching entries, or 'A' if what we want is the average of the weights of fish in all matching entries, or 'M' if what we want is the maximum of the weights of fish in all matching entries. If Query-Code is blank, we want all of the above.
Programming Notes
Write your own JCL for this assignment using the compiler and the loader. The loader PARM should be 'MAP,LET'. Do not allow the loader step to execute if the compiler's return code was not 0.
Use the Author and Date-Compiled lines in the Identification Division of your program.
Print a page heading in your report. Triple-space between the page heading and the column headings. Center the output neatly on the page. Include page numbers.
Obtain the current date from the system using the Accept verb and include it in DD-MM-YYYY format in the heading on each page.
Include your own name on each page of the report: 'Prepared by ________', centered.
The large table must be indexed, but any other tables used in this assignment may be either indexed or subscripted.
You may find it useful to create some other tables, listing the name of the 8 boats, the names of the 6 bays, and the names of the 3 kinds of fish. The names of the boats and bays should be obtained from the input, not hard-coded in your program.
You may find it useful to use the Display verb in developing and debugging your program.
In printing the result of a query, you should print out the values of the fields left blank (or zero) in the query record. If you are printing out a maximum value, you should print afterward the values of the fields where the maximum occurred. See the sample output.
Do not assume the data in the query records is valid. You should check the data. If anything is wrong, you will not be able to process the query, so your program should print one or more error messages stating what is wrong.
Examples of queries
Example 1: Suppose the query record specifies 'S' as Query-Code, 'BABY LYN' as the boat name and 'ANILAO' as the bay name and leaves the fish name and trip number blank. Then we print the sum of the amounts of all three kinds of fish caught by BABY LYN in the bay called ANILAO.
Example 2: Suppose the query record specifies 'M' as Query-Code, leaves the boat name, the bay name and the trip number blank and specifies 'TUNA' as the fish name. Then the number we print is the maximum of the amounts of tuna caught by all boats in all bays on all trips.
Example 3: Suppose the query record specifies 'M' as Query-Code, 'SANTA ROSA' as the boat name, leaves the bay name blank and has trip number 0, and specifies 'TUNA' as the fish name. Then the number we print is the maximum of the amounts of TUNA caught by SANTA ROSA in any bay on any trips.
Example 4: Suppose the query record specifies 'S' as Query-Code, leaves the boat name blank, specifies 'Some Bay' as the bay name, has 0 as the trip number and has 'MOONFISH' as the fish name. Then this is an invalid query, and we want to print an error message.
About the data
As some of the data used in this program is in binary or packed decimal formats, you may experience difficulty in printing the data. You can use the IEBPTPCH utility to obtain a printed copy of the data in character format with the two files concatenated. Notice this is actually a different file, with 80-byte records: KC02314.SUMMER09.CSCI465.HW5.COMBINED
Hints
As there are a number of different kinds of queries, it is not practical to write a separate subroutine to carry out each one.
Hint #1: We are always looking for a total, average or a maximum. It may be easiest to calculate all three regardless of what is requested and then just print what is needed.
Hint #2: We are always searching some portion of the large table. The part we are searching can always be described as having each index within a range of values. The obvious way to do this is to have nested Perform-Varying loops, where in each loop we have "Perform Varying Index from Value1 to Value2". We can always use the same structure with different values of Value1 and Value2 for each index. (Notice that we could have Value1 = Value2.)