home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Between Heaven & Hell 2
/
BetweenHeavenHell.cdr
/
100
/
57
/
mngmonry.arc
/
MNTHINCM.BAS
< prev
next >
Wrap
BASIC Source File
|
1986-07-19
|
3KB
|
69 lines
100 ' Monthly income ("MNTHINCM")
110 CLS
120 COLOR 0,15 : PRINT "Monthly Income" : COLOR 15,0
130 DEFDBL A-Z
140 DEFINT M-N
150 'Define rounding function
160 DEF FNR (V) = SGN (V) * INT (ABS (V) * 100 + .5) / 100
170 MONEYFMT$ = "$$##,###,###.##"
180 ' Let user select results
190 PRINT : PRINT "Select desired result:"
200 PRINT
210 PRINT "1 - Initial deposit"
220 PRINT "2 - Required interest rate"
230 PRINT "3 - Monthly income"
240 PRINT "4 - Number of monthly withdrawals"
250 PRINT
260 INPUT "Result Number"; RESULT
270 IF RESULT < 1 OR RESULT > 4 THEN PRINT "Select 1-4 only" : GOTO 200
280 PRINT
290 ' Let user enter data
300 PRINT "Do not enter dollar signs or commas"
310 PRINT
320 IF RESULT <> 1 THEN INPUT "Initial deposit: ", PV
330 IF RESULT <> 2 THEN INPUT "Annual interest rate (in percent): ", AR
340 IF RESULT <> 3 THEN INPUT "Monthly income: ", INCOME
350 IF RESULT <> 4 THEN INPUT "Term (in months): ", NMONTHS
360 INPUT "Annual inflation rate (in percent): ", INFLATION
370 INPUT "Marginal tax rate (in percent): ", TAXRATE
380 ' Initialize values
390 PR = (1 + AR / 100) ^ (1 / 12) - 1 'Monthly interest rate
400 PR = PR * (1 - TAXRATE / 100) 'After - tax interest rate
410 'Monthly inflation rate
420 INFLATION = (1 + INFLATION / 100) ^ (1 / 12) - 1
430 'Effective interest rate
440 REFFECTIVE = (1 + PR) / (1 + INFLATION) - 1
450 PRINT
460 ON RESULT GOTO 480, 530, 670, 720
470 ' Result 1: Initial deposit
480 IF REFFECTIVE < > 0 THEN PV = INCOME * (1 + REFFECTIVE) / REFFECTIVE * (1 - (1 + REFFECTIVE) ^ - NMONTHS) ELSE PV = INCOME * NMONTHS
490 PRINT "Initial deposit: "; USING MONEYFMT$; PV
500 END
510 ' Result 2: Required interest rate
520 'Use bisection method
530 RLOWER = 0
540 RUPPER = .5
550 WHILE (RUPPER - RLOWER) > .00001
560 TRIALR = (RUPPER + RLOWER) / 2
570 REFFECTIVE = TRIALR * (1 - TAXRATE / 100)
580 REFFECTIVE = (1 + REFFECTIVE) / (1 + INFLATION) - 1
590 TRIALPMT = PV * REFFECTIVE / ( (1 + REFFECTIVE) * (1 - (1 + REFFECTIVE) ^ -NMONTHS) )
600 IF TRIALPMT > INCOME THEN RUPPER = TRIALR ELSE RLOWER = TRIALR
610 WEND
620 AR = (1 + (RUPPER + RLOWER) / 2) ^ 12 - 1
630 AR = AR * 100
640 PRINT "Required interest rate: "; FNR(AR); "%"
650 END
660 ' Result 3: Monthly income
670 IF REFFECTIVE <> 0 THEN INCOME = PV * REFFECTIVE / ((1 + REFFECTIVE) * (1 - (1 + REFFECTIVE) ^ -NMONTHS) ) ELSE INCOME = PV / NMONTHS
680 PRINT
690 PRINT "Monthly income : "; USING MONEYFMT$; INCOME
700 END
710 ' Result 4: Number of withdrawals
720 IF REFFECTIVE <> 0 THEN TMONTHS = INCOME / REFFECTIVE + 1
730 IF REFFECTIVE <> 0 THEN TMONTHS = LOG (TMONTHS / (TMONTHS - PV) ) / LOG (1 + REFFECTIVE)
740 IF REFFECTIVE = 0 THEN TMONTHS = PV / INCOME
750 IF (INT(TMONTHS) + 1 - TMONTHS) < .01 THEN NMONTHS = INT(TMONTHS) + 1 ELSE NMONTHS = INT(TMONTHS)
760 PRINT "Number of monthly withdrawals: "; NMONTHS
770 END