Loan Amortization on the QL

See all articles from CATS v5 n6
Author(s): Mark Fisher
Publication: CATS Newsletter
Pub Details: CATS v5 n6 (Volume 5, Issue 6)
Date: September 1987
Pages: 4-5

This Abacus spreadsheet program is a companion to the 2068 BASIC program by Al Strauss (CATS N/L April 1986). It was developed from the Loan program in the QL manual, and extended to include the yearly information as generated by Al’s program. Both programs provide monthly and yearly totals of interest and principal paid.

After looking over the first printed draft of this article, I could see that it might be pretty daunting. Try it! If you take it in little steps, it really isn’t impossible – and the cell duplication abilities of Abacus allow you to fill the 2000+ cells of this application with perhaps 100 entries. In addition, you can get useful information out of the program after stopping before Part Two.

The first step after loading Abacus, is to press F3-D to get to the design menu. Several of these settings need to be changed for our US standard printers. We want:

1) Blank on zero........yes
2) Form feed ...........no  (yes if you use fanfold paper)
3) Gaps between lines...no
4) Lines per page.......58  (66 is British standard)
5) Monetary symbol......    (blank - you don't want columns of $$$ in your spreadsheet)
6) Printer paper width..138 (characters wide - I set the printer driver for Abacus up to automatically switch the printer to compressed pitch.)

Now back to the main program.

at:  type:                         comments:

A1 "MORTGAGE REPAYMENT CALCULATOR
C2 rept("=",len(c1)) underlines C1
B4 "Loan
C4 askn("Amount of loan") equals INPUT in basic
H4 askn("Percentage interest rate")
B5 "Int rate
C5 h4/100 input converted to dec. fraction
Now press F3-U(nits); Cells,Percentage,Decimal places 2,Range c5

B6 "Term
C6 askn("Period of the loan in years [maximum = 35]")
you can extend this program beyond that if you like, but it'll take up a lot of room on your microdrive.
E5 "Mnth
F5 "Yr
D6 "Start
E6 askn("Month of first payment [1=Jan, 2=Feb, etc.]")
F6 askn("Start year ")
E7 '('+month(e6)+')' note single quotes
D8 "REPAYMENTS
Press F3-C(opy); from range c2, to cell d9

C10 "Monthly
C11 "Annual
D10 c4*(c5/12)/(1-(1+(c5/12))^(-c6*12))
D11 d10*12
D12 d9

Try F3-X(ecute) to see it work.
Press F3-U(nits),Cells,Monetary,Minus sign,c4
Press F3-U(nits),Default,Monetary,Minus sign
Press F3-J(ustify),Cells,Numbers,Left,Range a1:ao8

Looks better now, doesn’t it?

Part Two: the Repayment Table

Here’s where we really move away from the example in the QL manual. The manual’s layout provided only remaining balance by month, and was limited by the spreadsheet’s width. This version provides monthly and yearly figures on interest and principal paid as well. In addition, you could easily extend it to account for a 200 year repayment period!

at:  type:                         comments:

C15 "REPAYMENT TABLE
press F3-C(opy),from range C2, to cell C16
A17 "Year
C17 month((col()-3)/3+1) month names every third col.
C18 "Bal.
D18 "Int.
E18 "Princ.
Press F3-C,range C17:E18,to cell F17

A19 $F6+row()-19 puts year in first column
Press F3-C(opy),range A19,to cell A20

C19 if(col()/3=$E6,$C4,0) if this is the starting month, enter the balance; else, enter zero. The other 'bal.' columns have a slightly different formula to carry the current balance across if not zero (see cell F19, below).
D19 if(C19).005,$C5*C19/12,0)figures interest on balance
E19 if(C19).005,$D10-D19,0) figures princ. paid this mo.
F19 if(col()/3=$E6,$C4,C19-E19)
C20 if(AJ19-AL19).005,AJ19-AL19,0)

That’s almost all the formulas. Now to spread them around:

Press F3-C(opy),range D19:E19, to cell D20
Press F3-C(opy),range D19:E19, to cell G19
Press F3-C(opy),range F19:H19, to cell F20

Now to spread the formulas across the top of the table:

Press F3-C(opy),range F17:H20, to cell I17
Press F3-C(opy),range F17:K20, to cell L17
Press F3-C(opy),range F17:Q20, to cell R17
Press F3-C(opy),range F17:N20, to cell AD17

Now they’re all the way across. If you look at it, you’ll see “January” in every third cell, but don’t worry – it’ll straighten itself out when you first use it.

It’s time for the summary side of the table. First, we’ll copy the basic figures over above the totals columns, for easy reference:

Press F3-C(opy),range A1:F12, to cell AK1

We want the figures over there, but we don’t want a second copy of the setup formulas. So:

AM4  C4
Press F3-E(cho), cell AM4, over range AM5:AP11
AM16 "Totals for Year
Press F3-C(opy),range C2, to cell AM17

AM18 "Total interest paid
AO18 "Total principal paid

Press F3-E(cho), cell A19, over range AM19:AM54
AN19 D19+G19+J19+M19+P10+S19+V19+Y19+AB19+AE19+AH19+AK19

Phew! But you only have to type it once:

Press F3-E(cho), cell AN19, over range AN19:AO20

Now all of row 20 can be spread on down the table:

Press F3-C(opy),range A20:AO20 to cell A21
Press F3-C(opy),range A20:AO21 to cell A22
Press F3-C(opy),range A20:AO23 to cell A24
Press F3-C(opy),range A20:AO27 to cell A28
Press F3-C(opy),range A20:AO35 to cell A36
Press F3-C(opy),range A20:AO22 to cell A52

Time to try it out! I’ll include some portions of a sample printout – your figures should be identical to mine for the given loan value. I’ve checked this program against Al Strauss’s, and they match.

  !    A   !    B   !    C    !    D    !    E    !    F
 1!MORTGAGE REPAYMENT CALCULATOR
 2!=============================
 3!
 4!         Loan        2000.00
 5!         Int rate     13.00%            Mnth       Yr
 6!         Term              4 Start      2          1776
 7!                                       (February)
 8!                             REPAYMENTS
 9!                             ----------
10!                   Monthly        53.65
11!                   Annual        643.86
12!                             ----------
13!                   goto AJ1 for yearly totals
14!
15!                   Repayment Table
16!                   ===============
17!Year              January                       February
18!                   Bal.      Int.      Princ.    Bal.
19!     1776                                        2000.00
20!     1777        1628.44     17.64      36.01   1592.42
21!     1778        1169.57     12.67      40.98   1128.59
22!     1779         647.37      7.01      46.64    600.72
23!     1780          53.08      0.58      53.08
24!     1781

  !   AK   !   AL   !   AM    !   AN    !   AO    !   AP
 1!MORTGAGE REPAYMENT CALCULATOR
 2!=============================
 3!
 4!         Loan        2000.00
 5!         Int rate     13.00%            Mnth       Yr
 6!         Term              4 Start      2          1776
 7!                                       (February)
 8!                             REPAYMENTS
 9!                             ----------
10!                   Monthly        53.65
11!                   Annual        643.86
12!
13!
14!
15!
16!                   Totals for Year
17!                   ===============
18!Int.      Princ.   Total interest paid  Total principal paid
19!   18.03     35.63    1776     218.64     371.56
20!   13.11     40.55    1777     184.99     458.87
21!    7.51     46.14    1778     121.66     522.20
22!    1.14     52.51    1779      49.57     594.29
23!                      1780       0.58      53.08
24!                      1781

Happy Accountanting!

MF

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.