COBOL - lab 5

Lab 5 - Simple Credit Card Application

Objectives:

Reading Assignment:

Read chapters 6 and 7 about moving data and arithmetic verbs.


The Last National Bank of White CT (with a branch office in Bruce CT) offers a Visa Card with a picture of their infamous namesake (i.e. Bruce White) on the card. The card has the following fields:

columns  1 - 16 - account number (read in but not printed)
columns 17 - 35 - customer name
columns 36 - 41 - previous balance (9999V99)
columns 42 - 47 - payments (9999V99)
columns 48 - 52 - unused  (FILLER PIC X(5)   )
columns 53 - 58 - new charges
columns 59 - 80 - unused  (FILLER PIC X(22)  )
NOTE!  Although not all input columns are used, you have to account for them.  Frequently COBOL programmers will say "FILLER" with the appropriate pic clause - like 05 FILLER   PIC X(05) - make sure you count the spaces properly - and also to account for 80 total input characters!!!  (Thus the last input file will be:  05                     PIC X(22).

You will prepare a report giving the customer name, previous balance, payments, new charges, finance charges and the new balance.

Order of calculations:

At the end of the report, give the total of these fields:

also calculate a "proof total" - which will be the total previous balance minus the total payments plus the total finance charges and the total new charges. This figure should equal the total new balance (as a verification that the other calculations were okay).


Special features:

- for many of the accounts, the customer paid more than was owed (i.e. the payments-in is greater than the previous-balance) - therefore the unpaid-balance will be negative! To handle a negative value in COBOL, you will need a picture clause with a leading "S" (for signed number):  (but, what would you expect for customers of the Last National Bank of  White?)

05 UNPAID-BALANCE PIC S99999V99.

(Likewise, the new balance could be negative as well!)

To calculate the finance charge, you will need a simple IF statement like this:


SUBTRACT PAYMENTS-IN FROM PREVIOUS-BALANCE-IN GIVING
           UNPAID-BALANCE.
IF UNPAID-BALANCE > 0
    MULTIPLY UNPAID-BALANCE BY .01 GIVING FINANCE-CHARGE
ELSE
    MOVE ZERO TO FINANCE-CHARGE
END-IF.

Your output should look something like this:

The data file is like this:

Return to Internet COBOL Main page

Last modified by Bruce White on 02/26/04