Pascal Memorial Library
|Time to complete||Allow 4-6 hours continuous.|
|Program Download||LibRoyaltyRpt.Cbl is a model answer. Don't look at this until you have made your own attempt at the program.|
Royalties.Rpt is the report produced by processing the two indexed files.
|Major Constructs||Indexed Files, Print Files, READ..NEXT RECORD, READ..KEY IS, START, REWRITE, WRITE, MULTIPLY, SET|
Each time a book is borrowed, the Pascal Memorial Library pays the author a small sum of money as royalty. Because the sum owed for each "borrowing" is very small, royalties are only paid once every quarter. Royalties are paid to authors through their agents. Only one cheque per quarter is sent to each agent but to allow him to pay his authors the correct amount, a breakdown of the royalties owed to each author is included with the cheque.
A report is required which;
The report must be printed in agent name sequence. The sequence of authors
within each agent and of books within each author does not matter. The
print specification for the report is on the last page.
All the data required to produce the Royalty Payment Report is contained in two indexed files.
The indexed file Books.Dat has the following record description;-
The indexed file Author.Dat has the following record description;-
Some fields required in the report do not appear in either of the indexed files and must be calculated. The following describes these fields and how to calculate them;
Book-Royalty contains the royalty to be paid for a book for the quarter. It is obtained by multiplying Quarter-Borrowings by Royalty-Rate. It is a numeric field with up to three places before the decimal point and two places after.
Quarter-Author-Borrows contains the sum of Quarter-Borrowings for all of an authors books on loan in the library. It is a numeric field up to four digits long.
Author-Royalties is the sum of an author's Book-Royaltys. It is a numeric field with up to four places before the decimal point and two after.
Agent-Payment is the sum of an agent's Author-Royalties. It is a numeric field with up to six places before the decimal point and two after it.
In addition to producing the report the program must perform a small update on the Quarter-Borrowings field of the Books file. When all the calculations involving the Quarter-Borrowings field have been done, it must be set to zero so that the borrowings for the new quarter may be accumulated.
Notes: There is no need to allow for page breaks.