Elementary Account Aging Program
(with documentation)

NOTE to Bruce - change this!!!

Develop a COBOL program to "age" accounts. Aging of accounts is where a business charges late fees or interest to accounts that are not paid on time. It is a major revenue source for various charge accounts and a standard business practice.


We will deal with a data file that has an account number, customer name, birthdate (in form YYYYMMDD) and the date of last payment on their account  (YYYYMMDD). 

Here is the data file link  (changed 08/11/2001)


Processing:

Write a program to calculate and print the (a) age of the customer and (b) the number of days since they last made a payment.

Look up the "Intrinsic Functions" section in the index (newer book is on pages 276 - 280).  You will want to use the date functions (page 277).  Get the Current-Date-And-Time (this gives us the date as an 8 digit number YYYYMMDD).  Then use the INTEGER-OF-DATE function (page 277) to calculate the number of days difference.  To get the age - divide the total days difference by 365.25.  To calculate the number of days since the last payment, just find the days difference with the Integer-Of-Date function.

You would then in the 2000-initialize have:

MOVE FUNCTION CURRENT-DATE TO CURRENT-DATE-AND-TIME

In the processing:

COMPUTE DAYS-DIFFERENCE = FUNCTION INTEGER-OF-DATE(THIS-DATE)
- FUNCTION INTEGER-OF-DATE(BIRTHDAY-IN)
COMPUTE AGE = DAYS-DIFFERENCE / 365.25

COMPUTE DAYS-DIFFERENCE = FUNCTION INTEGER-OF-DATE(THIS-DATE)
              - FUNCTION INTEGER-OF-DATE(LAST-PAYMENT-IN)
MOVE DAYS-DIFFERENCE        TO DAYS-LATE


Additional requirements: Documentation.

Working programs need documentation. Frequently programmers other than the original developer must modify programs and additional internal documentation is very helpful!

Requirements:

Before each procedure - add comment lines like this:


****************************************************************************
*             E N V I R O N M E N T    D I V I S I O N                     *
****************************************************************************

Before any sections - give comment lines that have an asterisk in column 7 and then asterisks from column 40 to column 72 (for the first and third line) and then for the middle line an asterisk in column 7 and column 40, and in columns 41 to 71 identify the section name and then an asterisk in column 72. Like this:


*                               ************************************
*                               *  WORKING-STORAGE SECTION         *
*                               ************************************

In the data division put a similar comment before each 01 structure (like detail line, output structure, etc.)

In the procedure division put a similar comment before each paragraph, plus put similar comments to identify what is happening before the coding - like: MOVE AND SET UP DETAIL LINE; READ NEXT RECORD; CALCULATE AGE

Additional requirement:

Code all variables with upper-case letters.

Do NOT use any literals in the procedure division - for example - AT END MOVE 'YES' TO END-OF-FILE - will need to be changed to AT END MOVE YES-LITERAL TO END-OF-FILE

and define YES-LITERAL as PIC XXX value 'YES'.


My sample output (4/18/2000)

Back to main COBOL page