Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50110/pvror.tuk
There are 2 other files named pvror.tuk in the archive. Click here to see a list.
10' NAME--PV-ROR
20'
30' DESCRIPTION--PRESENT VALUE AND MULTIPLE RATES OF RETURN
40' 
50' SOURCE--UNKNOWN
60'
70' INSTRUCTIONS
71 'THIS PROGRAM COMPUTES PRESENT VALUE AND RATE OF RETURN OF A 
72 'STREAM OF CASH FLOWS.  DATA LINES START WITH LINE 2180.  THE 
73 'FIRST NUMBER IS THE NUMBER OF FLOWS, THE SECOND IS THE NUMBER
74 'OF PERIODS FOR THE FIRST FLOW (EXCLUDING PERIOD ZERO).  THE THIRD
75 'NUMBER IS THE CASH FLOW IN PERIOD ZERO OF THE FIRST FLOW, THE
76 'FOURTH NUMBER IS THE FLOW IN PERIOD ONE OF THE FIRST FLOW,ETC.
77 'AFTER TYPING IN THE FIRST FLOW, TYPE IN THE NUMBER OF PERIODS IN
78 'THE SECOND FLOW, AND THEN THE FLOWS PERIOD BY PERIOD,UNTIL
79 'ALL FLOWS ARE INCLUDED.  MAKE INCOME PLUS AND OUTLAYS MINUS.
80 'BE SURE THE SAMPLE DATA IN LINES 2180-2220 HAS BEEN DELETED
81 'BEFORE RUNNING.
90'
100' THIS PROGRAM WAS WRITTEN FOR STUDENT USE AT AMOS TUCK SCHOOL
101' OF HANOVER, N.H. WHICH DOES NOT ASSUME RESPONSIBILITY FOR
102' ITS ACCURACY.
110'
120' * * * * * * * * * * MAIN PROGRAM * * * * * * * * * * * * 
130'
160 DIM P(124),Q(124),R(124),E(60),M(124),Y(1200)
170 LET A=B=K=N=S=U=V=X=T1=T2=P1=P2=0
210 PRINT
220 READ N8
230 FOR N7=1 TO N8
235 LET A=B=K=N=S=U=V=X=T1=T2=P1=P2=0
240 PRINT
250 PRINT
260 PRINT "CASH FLOW NO. ";N7
262 PRINT
264 READ N9
266 FOR N=0 TO N9
270 READ P(N)
330 IF P(N) = 0 THEN 390
340 LET T2 = T2 + 1
350 LET M(T2) = SGN(P(N))
360 IF T2 = 1 THEN 390
370 IF M(T2)+M(T2-1) <> 0 THEN 390
380 LET P1 = P1 + 1
390 LET Q(N) = P(N)
400 LET K = K + ABS(P(N))
420 NEXT N
430 PRINT
450 IF B > 0 THEN 520
460 PRINT "WHAT IS YOUR ESTIMATED COST OF CAPITAL IN %";
470 INPUT R
480 GOSUB 2090
490 PRINT
500 PRINT "THE PRESENT VALUE OF THIS STREAM OF FLOWS IS $"P
510 PRINT
520 IF N = 1 THEN 1140
530 IF N = 2 THEN 950
540 IF P(0) <> 0 THEN 600
550 FOR T = 0 TO N-1
560 LET Q(T) = Q(T+1)
570 NEXT T
580 LET B = B + 1
590 GO TO 450
600 LET C = 1 - V/2
610 LET D = 1
620 LET P = Q = 0
630 FOR  T = 0 TO N - A
640 LET P = P + Q(T)*(C^T)
650 LET Q = Q + T*Q(T)*(C^(T-1))
660 NEXT T
670 IF ABS(P) < K/1E9 THEN 820
680 IF ABS(P/Q) < 1E5 THEN 700
690 GOTO 760
700 LET C = C - P/Q
710 LET E(D) = P/Q
720 IF D < 10 THEN 800
730 FOR T = 0 TO 5
740 IF E(D-T) < E(D-T-1) THEN 790
750 NEXT T
760 IF V = 1 THEN 970
770 LET V = 1
780 GOTO 600
790 IF D > 50 THEN 760
800 LET D = D + 1
810 IF ABS(P/Q) > 1E-8 THEN 620
820 IF C <= 0 THEN 840
830 GOSUB 2140
840 LET V = 0
850 IF U = 1 THEN 1090
860 LET A = A + 1
870 FOR T = 1 TO N - A
880 LET Q(T) = Q(T) + Q(T-1)/C
890 NEXT T
900 IF ABS(Q(1)) > 1 THEN 930
910 IF N-A >2 THEN 600
920 GOTO 950
930 LET C = -Q(0)/Q(1)
940 IF N - A > 2 THEN 610
950 LET X = Q(1)^2-4*Q(0)*Q(2)
960 IF X >= 0 THEN 1050
970 IF (P1-P2)/2 = INT((P1-P2)/2) THEN 1180
980 PRINT
990 PRINT "WARNING---THIS PROGRAM HAS FAILED TO COMPUTE AT LEAST ONE"
1000 PRINT "MORE REAL SOLUTION FOR THE RATE OF RETURN > -100%.  YOU ARE"
1010 PRINT "THEREFORE ADVISED TO EXERCISE THE GRAPHICAL OUTPUT OPTION."
1020 PRINT
1030 IF P2 = 0 THEN 1200
1040 GOTO 1210
1050 IF Q(2) = 0 THEN 1130
1060 LET C = (-Q(1)+SQR(X))/(2*Q(2))
1070 LET U = 1
1080 GOTO 820
1090 LET C = (-Q(1)-SQR(X))/(2*Q(2))
1100 IF C <= 0 THEN 1180
1110 GOSUB 2140
1120 GOTO 1180
1130 PRINT "THE RATE OF RETURN IS-100%."
1140 IF Q(0) = 0 THEN 1180
1150 IF Q(1)/Q(0) >= 0 THEN 1180
1160 LET C = -Q(0)/Q(1)
1170 GOSUB 2140
1180 IF P2 > 0 THEN 1210
1190 PRINT "THERE ARE NO REAL SOLUTIONS FOR THE RATE OF RETURN >-100%."
1200 GO TO 1420
1210 IF P2 > 1 THEN 1260
1220 PRINT "THE RATE OF RETURN IS"R(1)"%."
1230 LET H = 5
1240 LET G = R(1)
1250 GOTO 1430
1260 PRINT "THE FOLLOWING ARE POSSIBLE SOLUTIONS FOR THE RATE OF RETURN:"
1270 LET G = -1E30
1280 LET H = 1E30
1290 FOR T = 1 TO P2
1300 PRINT R(T);"%",
1310 IF R(T) <= G THEN 1330
1320 LET G = R(T)
1330 IF R(T) >= H THEN 1350
1340 LET H = R(T)
1350 NEXT T
1360 IF H < 5 THEN 1380
1370 LET H = 5
1380 IF G < 100 THEN 1400
1390 LET G = 95
1400 IF G > 0 THEN 1420
1410 LET G = -5
1420 PRINT
1430 PRINT
1440 PRINT "WOULD YOU LIKE A PLOT OF PRESENT VALUE VS. COST OF CAPITAL";
1450 INPUT B$
1460 IF B$ = "YES" THEN 1480
1470 GOTO 1950
1480 LET G = INT(G)+5
1490 LET H = INT(H)-5
1500 FOR R = H TO G
1510 GOSUB 2090
1520 LET Y(R+100) = P
1530 NEXT R
1540 LET B1 = -1E30
1550 LET S1 = 1E30
1560 FOR T = H+100 TO G+100
1570 IF Y(T) < B1 THEN 1590
1580 LET B1 = Y(T)
1590 IF Y(T) > S1 THEN 1610
1600 LET S1 = Y(T)
1610 NEXT T
1620 IF SGN(B1)+SGN(S1) <> 0 THEN 1730
1630 IF ABS(S1) > B1/3 THEN 1660
1640 LET S1 = - B1/3
1650 GOTO 1730
1660 IF ABS(S1) > B1 THEN 1690
1670 LET S1 = -B1
1680 GOTO 1730
1690 IF ABS(S1) >= 3*B1 THEN 1720
1700 LET B1 = -S1
1710 GOTO 1730
1720 LET B1 = -S1/3
1730 PRINT
1740 PRINT "COC%"; TAB(27); "PRESENT VALUE ($)"
1750 FOR L = 0 TO 60 STEP15
1760 LET F = INT(100*(S1+L*(B1-S1)/60)+.5)/100
1770 IF ABS(F) > B1/1E5 THEN 1800
1780 LET F = 0
1790 LET T1 = L
1800 PRINT TAB(L+4); F ;
1810 NEXT L
1820 PRINT
1830 PRINT TAB(5);":....:....:....:....:....:....:....:....:....:....:....:....:"
1840 FOR T = H+100 TO G+100
1850 LET Y(T) = INT(60*(Y(T)-S1)/(B1-S1)+.5)
1860 IF Y(T) <> T1 THEN 1890
1870 PRINT T-100; TAB(Y(T)+5); "*"
1880 GOTO 1930
1890 IF Y(T) > T1 THEN 1920
1900 PRINT T-100; TAB(Y(T)+5); "*";TAB(T1+5); ":"
1910 GOTO 1930
1920 PRINT T-100; TAB(T1+5); ":"; TAB(Y(T)+5); "*"
1930 NEXT T
1940 PRINT TAB(5);":....:....:....:....:....:....:....:....:....:....:....:....:"
1950 PRINT
1960 PRINT "IF YOU WOULD LIKE A TABLE OF PRESENT VALUE VS. COST OF"
1970 PRINT "CAPITAL, ENTER LOWER & UPPER LIMITS  OF COST OF CAPITAL"
1980 PRINT "AND THE STEP, SEPARATED BY COMMAS; OTHERWISE PRESS RETURN."
1990 MAT INPUT J
2000 PRINT
2010 IF NUM=0 THEN 2075
2020 PRINT " COC","PRESENT VALUE"
2030 PRINT "  %","     $"
2040 FOR R = J(1) TO J(2) STEP J(3)
2050 GOSUB 2090
2060 PRINT R,P
2070 NEXT R
2075 NEXT N7
2080 STOP
2090 LET P = 0
2100 FOR T = 0 TO N+B
2110 LET P = P +P(T)/((1+R/100)^T)
2120 NEXT T
2130 RETURN
2140 LET P2 = P2 + 1
2150 LET R(P2) = 100*(1/C-1)
2160 IF P1 = P2 THEN 1180
2170 RETURN
2180 DATA 3
2190 DATA 5,-10000,2500,2500,2500,2500,2500
2200 DATA 3,-20000,10000,5000,5000
2210 DATA 4,20000,-25000,-5000,20000,10000
2220 END