home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Between Heaven & Hell 2
/
BetweenHeavenHell.cdr
/
100
/
57
/
mngmonry.arc
/
AMORTIZE.BAS
next >
Wrap
BASIC Source File
|
1986-08-08
|
2KB
|
57 lines
100 ' Amortize ("AMORTIZE")
110 CLS
120 COLOR 0,15 : PRINT "Amortize" : COLOR 15,0
130 PRINT
140 DEFDBL A-Z
150 DEFINT M-N
160 MONEYFMT$ = "$$##,###,###.##"
170 DEF FNR (V) = SGN (V) * INT (ABS (V) * 100 + .5) / 100
180 ' Let user enter amount, term, rate, starting date
190 INPUT "Loan amount: ", PNCPL
200 INPUT "Term in months: ", NMONTHS
210 INPUT "Annual interest rate (in percent): ", AR
220 PRINT "Enter date of first payment"
230 INPUT " Month (1-12): ", MONTH
240 IF MONTH < 1 OR MONTH > 12 THEN PRINT "No such month" : GOTO 230
250 INPUT " Year (1900-2100): ", YEAR
260 IF YEAR < 1900 OR YEAR > 2100 THEN PRINT "Year out of range" : GOTO 250
261 DIM TOTALPAYMENTS(600)
262 DIM TOTALINTEREST(600)
263 DIM PNCPL(600)
264 PNCPL(0) = PNCPL
270 ' Initialize variables
280 PR = AR / 1200 'Determine monthly interest rate
290 IF PR <> 0 THEN PMT = (PNCPL * PR) / (1 - (1 + PR) ^ -NMONTHS) ELSE PMT = PNCPL / NMONTHS
300 PMT = FNR (PMT) 'Monthly payment
310 PRINT : PRINT
320 PRINT "Monthly payment: "; USING MONEYFMT$; PMT
330 PRINT : PRINT
340 PRINT "Press space bar to see next month's results"
350 MONTHNUM = YEAR * 12 + MONTH
360 ' Calculate amortization table
370 FOR M = 1 TO NMONTHS
380 K$ = INKEY$ : IF K$ = "" THEN GOTO 380
390 INTERESTDUE = FNR (PNCPL * PR)
400 TOTALINTEREST = FNR (TOTALINTEREST + INTERESTDUE)
410 PNCPL = FNR (PNCPL - PMT + INTERESTDUE)
420 YEAR = (MONTHNUM - 1) \ 12
430 MONTH = MONTHNUM - YEAR * 12
440 MONTHNUM = MONTHNUM + 1
450 PRINT:PRINT
460 PRINT "Payment number: "; M
470 PRINT "Date: "; MONTH; "/"; YEAR
480 PRINT
490 PRINT "Principal: "; TAB(20); USING MONEYFMT$; PNCPL
500 PRINT "Total interest: "; TAB(20); USING MONEYFMT$; TOTALINTEREST
510 PRINT "Interest due: "; TAB(20); USING MONEYFMT$; INTERESTDUE
512 TOTALPAYMENTS(M) = TOTALPAYMENTS(M-1) + PMT
513 TOTALINTEREST(M) = TOTALINTEREST
514 PNCPL(M) = PNCPL
515 IF M>12 THEN PREV = M-12 ELSE PREV = 0
516 PRINT "Totals for previous 12 months"
517 PRINT "Payments:"; TAB(20); USING MONEYFMT$; TOTALPAYMENTS(M) - TOTALPAYMENTS(PREV)
518 PRINT "Interest paid:"; TAB(20); USING MONEYFMT$; TOTALINTEREST(M)-TOTALINTEREST(PREV)
519 PRINT "Repayment": PRINT " of principal:"; TAB(20); USING MONEYFMT$; PNCPL(PREV)-PNCPL(M)
520 NEXT M
530 END