1000 CLS:PRINT"    ANNUITY COMPUTATION  BY DR. PETER SHENKIN"
1002 PRINT"   AN ANNUITY IS ANY SET OF EQUAL PAYMENTS MADE AT
1003 PRINT"EQUAL INTERVALS OF TIME. WITH AN ORDINARY  ANNUITY
1004 PRINT"PAYMENTS ARE MADE AT THE ENDS OF THE  PERIODS  DE-
1005 PRINT"FINED BY THESE TIME INTERVALS. FOR AN ANNUITY  DUE
1006 PRINT"THE PAYMENTS ARE MADE AT THE BEGINNING OF THE PER-
1007 PRINT"IODS IN QUESTION.  THE PRESENT VALUE OF AN ANNUITY
1008 PRINT"IS THE AMOUNT OF CASH ONE WOULD ACCEPT NOW INSTEAD
1009 PRINT"OF THE SEQUENCE OF FUTURE PAYMENTS. BECAUSE  MONEY
1010 PRINT"HAS TIME VALUE (INTEREST IS CHARGED)  THE  PRESENT
1011 PRINT"VALUE DOES NOT EQUAL THE SUM OF THE PAYMENTS.  tHE
1012 PRINT"FUTURE VALUE OF AN ANNUITY IS THE  AMOUNT  OF CASH
1013 PRINT"WHICH WOULD ACCUMULATE BY THE END  OF THE  ANNUITY
1014 PRINT"IF THE INDIVIDUAL PAYMENTS ARE  INVESTED  AT   THE
1015 PRINT"PREVAILING INTEREST RATE.
1016 INPUT"PRESS ENTER TO CONTINUE";Z9$
1017 CLS:PRINT"MANY  ANNUITIES ALSO INVOLVE A LAST BALLOON PAY-
1018 PRINT"MENT.IN THE ANNUITY PROBLEMS WE EXAMINE,THE VARIABLES
1020 PRINT"OF INTEREST ARE  NUMBER OF PAYMENTS,INTEREST RATE PER 
1030 PRINT"PERIOD,PAYMENT PER PERIOD,PRESENT OR FUTURE VALUE,AND
1040 PRINT"BALLOON PAYMENT (AT END OF TERM) IF DESIRED.GIVEN ANY 
1045 PRINT"FOUR VALUES OF THE ABOVE VARIABLES THIS PROGRAM WILL
1050 PRINT"FIND THE FIFTH VARIABLE WHEN CONSIDERING THE PRESENT
1060 PRINT"VALUE SITUATION. IN THE FUTURE VALUE CASE NO BALLOON
1065 PRINT"PAYMENTS ARE CONSIDERED AS IN THIS CASE A  BALLOON
1067 PRINT"PAYMENT OF A CERTAIN AMOUNT WOULD ADD THAT AMOUNT 
1070 PRINT"TO FUTURE VALUE.NOTE THAT INTEREST RATES ARE WRITTEN 
1075 PRINT"AS PER CENTS, NOT AS DECIMALS(E.G. 6%, NOT .06). IN
1080 PRINT"ADDITION NOTE THAT INTEREST RATE IS PER PERIOD,I.E.
1085 PRINT"PER MONTH,PER YEAR,ETC.
1090 PRINT:INPUT"PRESS ENTER TO BEGIN";Z9:CLS
1095 CLS
1100 PRINT"SELECT TYPE OF PROBLEM DESIRED."
1105 PRINT"     0.QUIT"
1110 PRINT"     1.ORDINARY ANNUITY-FUTURE VALUE(SINKING FUND)
1120 PRINT"     2.ANNUITY DUE-FUTURE VALUE
1130 PRINT"     3.ORDINARY ANNUITY-PRESENT VALUE
1140 PRINT"     4.ANNUITY DUE-PRESENT VALUE
1150 PRINT:INPUT"MAKE YOUR CHOICE";C
1153 IF C = 0 THEN END
1155 PRINT:INPUT"IS INTEREST RATE QUOTED PER PERIOD(P) OR ANNUALLY(A)";ZI$
1157 IF ZI$<>"P" AND ZI$<>"A" THEN PRINT"INPUT ERROR":GOTO 1155
1158 IF ZI$="A" THEN PRINT:INPUT"NUMBER OF PAYMENTS PER YEAR";ZN
1160 ON C GOTO 1200,1300,1400,1500
1200 REM"ORDINARY ANNUITY-FUTURE VALUE TYPE PROBLEM
1210 CLS
1220 GOSUB 3000
1223 I=I/100
1225 IF FV=9999 THEN FV=PMT*((1+I)[N-1)/I
1230 IF PMT=9999 THEN PMT=FV*I/((1+I)[N-1)
1240 IF N=9999 THEN N=LOG((FV*I/PMT+1))/LOG(1+I)
1250 IF ABS(I-99.99)<.01 THEN GOSUB 4000
1260 GOTO 5000:REM PRINTOUT
1300 GOSUB 3000
1310 I=I/100
1325 IF FV=9999 THEN FV=PMT*(1+I)*((1+I)[N-1)/I
1330 IF PMT=9999 THEN PMT=FV*I*(1/(1+I))/((1+I)[N-1)
1340 IF N=9999 THEN N=LOG((FV*I/(PMT*(1+I))+1))/LOG(1+I)
1350 IF ABS(I-99.99)<.01 THEN GOSUB 4100
1360 GOTO 5000:REM PRINTOUT
1400 GOSUB 3000:GOSUB 3080
1405 I=I/100
1410 IF PV=9999 THEN PV=PMT*(1/I)*(1-(1+I)[(-N))+BAL*(1+I)[(-N)
1420 IF PMT=9999 THEN PMT=(PV-BAL*(1+I)[(-N))*I/(1-(1+I)[(-N))
1430 IF N=9999 THEN T=(BAL*I-PMT)/(PV*I-PMT):N=LOG(T)/LOG(1+I)
1440 IF BAL=9999 THEN BAL=PV-PMT*(1/I)*(1-(1+I)[(-N)):BAL=BAL*(1+I)[N
1450 IF ABS(I-99.99)<.01 THEN GOSUB 4200
1460 GOTO 5000
1500 GOSUB 3000:GOSUB 3080
1510 I=I/100
1520 IF PV=9999 THEN PV=PMT*(1+I)*(1/I)*(1-(1+I)[(-N))+BAL*(1+I)[(-N)
1525 IF PMT=9999 THEN PMT=(PV-BAL*(1+I)[(-N))*I/(1+I)/(1-(1+I)[(-N))
1530 IF N=9999 THEN T=(BAL*I-PMT*(1+I))/(PV*I-PMT*(1+I)):N=LOG(T)/LOG(1+I)
1540 IF BAL=9999 THEN BAL=PV-PMT*(1+I)*(1/I)*(1-(1+I)[(-N)):BAL=BAL*(1+I)[N
1550 IF ABS(I-99.99)<.01 THEN GOSUB 4300
1560 GOTO 5000
3000 REM INPUT SBR
3010 CLS:PRINT"ENTER EACH OF THE FOLLOWING.FOR THE UNKNOWN VALUE
3020 PRINT"ENTER 9999.":PRINT
3030 IF C<3 THEN INPUT"FUTURE VALUE               ";FV
3035 IF C>=3 THEN INPUT"PRESENT VALUE              ";PV
3040 INPUT"PAYMENT                    ";PMT
3050 INPUT"NUMBER OF PAYMENTS         ";N
3055 IF ZI$="A" THEN INPUT"ANNUAL INTEREST RATE       ";I
3056 IF ZI$="A" AND I<>9999 THEN I=I/ZN
3057 IF ZI$="A" THEN GOTO 3070
3060 INPUT"INTEREST RATE PER PERIOD(%)";I
3070 RETURN
3080 INPUT"BALLOON PAYMENT            ";BAL
3090 RETURN
4000 REM I FOR FV REG. ANNU.-SINKING FUND
4010 I=.01
4020 P=FV-PMT/I*((1+I)[N-1)
4025 D=PMT*(N*(1+I)[(N-1)/I- ((1+I)[N-1)/I[2)
4027 D=-D
4030 GOSUB 4600
4040 IF ABS(P)<=.1 THEN RETURN
4050 GOTO 4020
4100 REM I FOR FV ANNUITY DUE
4110 I=.01
4120 P=FV-PMT*(1+I)/I*((1+I)[N-1)
4125 D=PMT*((N+1)*(1+I)[N-1)/I-PMT*((1+I)[(N+1)-1-I)/I[2
4127 D=-D
4130 GOSUB 4600
4140 IF ABS(P)<=.1 THEN RETURN
4150 GOTO 4120
4200 REM I FOR PV/ORDINARY ANNUITY
4210 I=.01
4220 P=PMT/I*(1-(1+I)[(-N))+BAL*(1+I)[(-N)-PV
4225 D=N*PMT/(I*(1+I)[(N+1))-PMT/(I[2)*(1-(1+I)[(-N))-N*BAL/(1+I)[(N+1)
4230 GOSUB 4600
4240 IF ABS(P)<=.1 THEN RETURN
4250 GOTO 4220
4300 REM I FOR PV/ANNUITY DUE
4305 I=.01
4310 P=PMT*(1+I)/I*(1-(1+I)[(-N))+BAL*(1+I)[(-N)-PV
4320 D=(1+I)*(N*PMT/(I*(1+I)[(N+1))-PMT/(I[2)*(1-(1+I)[(-N)))+PMT/I*(1-(1+I)[(-N))-N*BAL/(1+I)[(N+1)
4330 GOSUB 4600
4335 IF ABS(P)<.1 THEN RETURN
4340 GOTO 4310
4600 REM COMPUTATION
4610 I=I-P/D
4620 RETURN
5000 REM PRINT OUT
5010 CLS
5020 IF C=1 OR C=2 THEN PRINT"FUTURE VALUE        =";FV
5025 IF C=3 OR C=4 THEN PRINT"PRESENT VALUE       =";PV
5030 PRINT"NUMBER OF PAYMENTS  =";N
5033 IF ZI$="A" THEN PRINT "     CONSISTING OF ";ZN;" PAYMENTS ANNUALLY."
5035 IF ZI$="A" THEN PRINT"ANNUAL INTEREST RATE  =";100*I*ZN:GOTO 5050
5040 PRINT"INT. RATE PER PERIOD=";100*I
5050 PRINT"PAYMENT             =";PMT
5060 IF C=3 OR C=4 THEN PRINT"BALLOON PAYMENT     =";BAL
5090 PRINT:INPUT"PRESS ENTER FOR MORE";Z9
5100 GOTO 1095
