Trailing-Edge
-
PDP-10 Archives
-
decus_20tap1_198111
-
decus/20-0020/capbud.tuk
There are 2 other files named capbud.tuk in the archive. Click here to see a list.
5' NAME--CAPBUD
10'
15' DESCRIPTION--GIVES INTERNAL RATE OF RETURN & COMPARES 4 PROJECTS
20'
25' SOURCE--UNKNOWN
30'
35' THIS PROGRAM WAS WRITTEN FOR STUDENT USE AT AMOS TUCK SCHOOL
40' OF HANOVER,N.H., WHICH DOES NOT ASSUME RESPONSIBILITY FOR
45' ITS ACCURACY.
50'
55' * * * * * * * * * * * MAIN PROGRAM * * * * * * * * * * * *
60'
88 DIM F(50),Y(15),U(50)
89 DIM A(4,50),B(4,50),T(4,50),V(4,50),Z(10,50)
90 PRINT "DO YOU WANT THE INSTRUCTIONS(YES OR NO)";
91 INPUT C$
92 IF C$="NO" THEN 1000
100 PRINT " ******INSTRUCTIONS FOR CAPBUD **********"
101 PRINT
102 PRINT
103 PRINT " 1. ENTER THE PROJECTS FROM SHORTEST TO LONGEST"
104 PRINT " 2. WHEN THE PROGRAM ASKS FOR DATA ALWAYS SEPARATE"
105 PRINT " THE DATA BITS BY COMMAS(EX. 7,8)"
106 PRINT " 3. OUTLAYS SHOULD BE PROCEEDED WITH A MINUS SIGN"
107 PRINT " 4. IF AN ERROR IS MADE TYPING IN DATA, TYPE SHIFT"
108 PRINT " AND THE LETTER O AT THE SAME TIME; THEN RETYPE DATA."
109 PRINT " 5. AFTER INPUTING DATA ALWAYS PUSH THE RETURN BUTTON."
110 PRINT " 6. INTEREST RATES AND INTERVALS MUST BE INTEGERS."
111 PRINT " 7. THE PROGRAM IS ONLY CAPABLE OF 50 PERIODS"
150 PRINT "******************************************************"
155 PRINT
156 PRINT
1000 REM ******INPUT SECTIONS FOR PROJECTS AND DATA
1010 PRINT " DO YOU WANT 1,2,3 OR 4 PROJECTS";
1015 INPUT P9
1020 ON P9 GO TO 1040,1060,1080,1100
1040 PRINT "HOW MANY FLOWS ARE IN YOUR PROJECT";
1045 INPUT Y(1)
1050 GO TO 1115
1060 PRINT "ENTER IN ORDER THE NUMBER OF FLOWS IN THE TWO PROJECTS"
1065 INPUT Y(1),Y(2)
1080 PRINT "ENTER IN ORDER THE NUMBER OF FLOWS IN THE THREE PROJECTS"
1085 INPUT Y(1),Y(2),Y(3)
1086 GO TO 1115
1100 PRINT "ENTER IN ORDER THE NUMBER OF FLOWS IN THE FOUR PROJECTS"
1102 INPUT Y(1),Y(2),Y(3),Y(4)
1103 GO TO 1115
1115 FOR X=0 TO P9
1116 GOSUB 1118
1117 GO TO 1248
1118 IF X=0 THEN 1240
1119 LET Y=INT (Y(X)/10)
1120 PRINT"****************DATA FOR PROJECT";X;"***********************"
1121 IF Y<1 THEN 1150
1122 PRINT "ENTER THE INITIAL FLOW THEN FLOWS 1 THRU 9"
1125 FOR P=1 TO Y
1127 IF P=1 THEN 1130
1128 PRINT "ENTER THE FLOWS FROM PERIOD";10*P-10;"THRU";10*P-1
1130 GOSUB 1900
1140 INPUT F(A0),F(A1),F(A2),F(A3),F(A4),F(A5),F(A6),F(A7),F(A8),F(A9)
1145 NEXT P
1150 LET Y5=INT(Y(X)/5)
1151
1152 IF Y5 >=1 THEN 1175
1155 ON Y(X) GO TO 1156,1160,1164,1168
1156 PRINT"ENTER THE FLOW";
1157 INPUT F(0)
1158 GO TO 1240
1160 PRINT " ENTER THE TWO FLOWS SEPARATED BY COMMAS"
1161 INPUT F(0),F(1)
1162 GO TO 1240
1164 PRINT "ENTER IN ORDER THE THREE FLOWS SEPARATED BY COMMAS."
1165 INPUT F(0),F(1),F(2)
1166 GO TO 1240
1168 PRINT "ENTER IN ORDER THE FOUR FLOWS SEPARATED BY COMMAS."
1169 INPUT F(0),F(1),F(2),F(3)
1170 GO TO 1240
1175 IF INT(Y5/2)=Y5/2 THEN 1200
1182 GOSUB 1915
1185 INPUT F(B1),F(B2),F(B3),F(B4),F(B5)
1200 LET Y6=Y(X)-(5*Y5)
1205 GOSUB 1925
1210 ON Y6+1 GO TO 1240,1232,1228,1224,1220
1220 PRINT "ENTER LAST FOUR FLOWS"
1221 INPUT F(C1),F(C2),F(C3),F(C4)
1222 GO TO 1240
1224 PRINT "ENTER LAST THREE FLOWS"
1225 INPUT F(C1),F(C2),F(C3)
1226 GO TO 1240
1228 PRINT "ENTER LAST TWO FLOWS"
1229 INPUT F(C1),F(C2)
1230 GO TO 1240
1232 PRINT "ENTER LAST FLOW"
1233 INPUT F(C1)
1240 FOR N=0 TO Y(X)-1
1242 LET B(X,N)=F(N)
1244 NEXT N
1246 PRINT
1247 RETURN
1248 PRINT
1250 NEXT X
1600 PRINT "**************END OF DATA FOR PROJECTS*************************"
1602 GOSUB 2000
1603 PRINT
1604 PRINT
1605 PRINT "DO YOU WANT TO HAVE THE PRESENT AND TERMINAL VALUES"
1606 PRINT "COMPUTED OVER A RANGE OF DISCOUNT RATES?(YES OR NO)"
1610 INPUT A$
1615 IF A$="NO"THEN 1650
1620 PRINT "ENTER THE DISCOUNT RATE RANGE AND THE INTERVALS BETWEEN"
1621 PRINT "OBSERVATIONS. EXAMPLE 6% TO 25% WITH INTERVALS OF 1%"
1622 PRINT "WOULD BE (6,25,1)";
1625 INPUT R1,R2,I
1647 GO TO 2500
1650 PRINT "ENTER THE DISCOUNT RATE(EX. 6% IS6)."
1655 INPUT R
1660 GO TO 7000
1900 REM ****SUBSCRIPTING SUBROUTINE**********
1902 LET A1=10*P-9
1903 LET A2=10*P-8
1904 LET A3=10*P-7
1905 LET A4=10*P-6
1906 LET A5=10*P-5
1907 LET A6=10*P-4
1908 LET A7=10*P-3
1909 LET A8=10*P-2
1910 LET A9=10*P-1
1911 RETURN
1915 LET B1=5*Y5-5
1916 LET B2=5*Y5-4
1917 LET B3=5*Y5-3
1918 LET B4=5*Y5-2
1919 LET B5=5*Y5-1
1920 RETURN
1925 LET C1=5*Y5
1926 LET C2=5*Y5+1
1927 LET C3=5*Y5+2
1928 LET C4=5*Y5+3
1929 RETURN
2000 REM ***********INTERNAL RATE OF RETURN***************
2010 PRINT
2012 PRINT
2020 FOR X=0 TO P9
2022 IF X=0 THEN 2360
2025 IF X>1 THEN 2040
2030 PRINT "******************THE INTERNAL RATE OF RETURN******************"
2035 PRINT "PROJECT 1","PROJECT 2","PROJECT 3", "PROJECT 4"
2036 PRINT "---------","---------","---------", "---------"
2040 FOR R=.01 TO 1.00 STEP .01
2045 LET U(X)=0
2060 FOR P=0 TO (Y(X)-1)
2080 LET U(X)=U(X)+(B(X,P)*((1+R)^(-P)))
2100 NEXT P
2120 IF U(X)<=0 THEN 2160
2140 LET R(X)=R
2160 NEXT R
2200 LET R(X+4)=R(X)+.01
2220 FOR R=R(X) TO R(X+4) STEP.0001
2225 LET U(X)=0
2240 FOR P=0 TO Y(X)
2260 LET U(X)=U(X)+(B(X,P)*((1+R)^(-P)))
2280 NEXT P
2300 IF U(X)<0 THEN 2340
2320 LET R(X)=R
2340 NEXT R
2355 PRINT R(X),
2360 NEXT X
2399 RETURN
2500 FOR X=0 TO P9
2501 PRINT
2502 PRINT
2504 PRINT "********************PROJECT";X"****************************"
2510 PRINT "DISCOUNT RATE";TAB(30)"PRESENT VALUE";TAB(50)"TERMINAL VALUE"
2515PRINT "-------------";TAB(30)"-------------";TAB(50)"--------------"
2520 FOR R=R1 TO R2 STEPI
2535 LET V(X,R)=T(X,R)=0
2540 FOR P=0 TO Y(X)-1
2555 LET H1=Y(X)-(P+1)
2556 IF B(X,P)<0 THEN 2580
2560 LET T(X,R)=T(X,R)+(B(X,P)*(1+(R/100))^H1)
2580 LET V(X,R)=V(X,R)+(B(X,P)*(1+(R/100))^(-P))
2600 NEXT P
2605 PRINT TAB(5);R;"%";TAB(35);V(X,R);TAB(55);T(X,R)+B(X,0)
2620 NEXT R
2640 NEXT X
3000 REM ***********THE UNEQUAL LIFE PROBLEM**********************
3002 LET Y(5)=Y(2)-Y(1)
3003 LET Y(6)=Y(3)-Y(1)
3004 LET Y(7)=Y(4)-Y(1)
3005 LET Y(8)=Y(3)-Y(2)
3006 LET Y(9)=Y(4)-Y(2)
3007 LET Y(10)=Y(4)-Y(3)
3010 IF Y(1)>=Y(2) THEN 3100
3012 LET N=2
3020 FOR X=N TO P9+1
3021 IF X=P9+1 THEN 3080
3022 GOSUB 3025
3023 GO TO 3040
3025 PRINT
3030 PRINT "THE COMPARISON OF PROJECTS 1("Y(1)" YEARS) & "X"("Y(X)"YEARS."
3032 PRINT "ORIGINAL DISCOUNT RATE";TAB(40)"RE-INVESTMENT RATE"
3034 PRINT "----------------------";TAB(40);"------------------"
3035 RETURN
3040 FOR R=R1 TO R2 STEP I
3050 LET Z(X+3,R)=((T(X,R)+B(X,0))/(T(1,R)+B(1,0)))^(1/Y(X+3))-1
3070 NEXT R
3080 NEXT X
3090 GO TO 3200
3100 IF Y(1)>=Y(3) THEN 3150
3110 LET N=3
3120 GO TO 3020
3150 IF Y(1)>=Y(4) THEN 4000
3160 LET N=4
3170 GO TO 3020
3200 IF Y(2)>=Y(3) THEN3300
3205 LET N=3
3210 FOR X=N TO P9+1
3212 IF X=P9+1 THEN 3280
3215 GOSUB 3220
3217 GO TO 3250
3220 PRINT "COMPARISON OF PROJECTS 2("Y(2)" YRS) & "X"("Y(X)"YRS)"
3230 PRINT "ORGINAL DISCOUNT RATE"; TAB (40)"RE-INVESTMENT RATE"
3240 PRINT "---------------------";TAB(40)"------------------"
3245 RETURN
3250 FOR R=R1 TO R2 STEP I
3255LET Z(X+5,R)=((T(X,R)+B(X,0))/(T(2,R)+B(2,0)))^(1/Y(X+5))-1
3260 PRINT TAB(7);R;"%";TAB(45);Z(X+5,R)*100;"%"
3270 NEXT R
3280 NEXT X
3290 GO TO 3400
3300 IF Y(2)>=Y(4) THEN 4000
3310 LET N=4
3320 GO TO 3210
3400 IF Y(3)>=Y(4) THEN 4000
3410 GOSUB 3420
3420 PRINT " COMPARISON OF PROJECT 3("Y(3)" YRS) & PROJECT 4("Y(4)" YRS)"
3430 PRINT "ORGINAL DISCOUNT RATE";TAB(40);"RE-INVESTMENT RATE"
3435 PRINT "---------------------"; TAB(40);"------------------"
3437 RETURN
3440 FOR R =R1 TO R2 STEP I
3450 LET Z(10,R)=((T(4,R)+B(4,0))/(T(3,R)+B(3,0)))^(1/Y(10))-1
3460 PRINT TAB(7);R;"%"; TAB(45); Z(10,R)*100;"%"
3470 NEXT R
4000 REM *****PLOTTING SUBROUTINE******
4010 PRINT "DO YOU WANT A PLOT OF THE PRESENT VALUE PROFILES OF"
4020 PRINT "THE PROJECTS";
4030 INPUT B$
4035 IF B$="YES" THEN 4100
4040 GO TO 6000
4100 LET Q3=1E30
4102 LET Q4=-1E30
4103 PRINT "PROJECT ONE------*"
4104 PRINT "PROJECT TWO------."
4105 PRINT "PROJECT THREE----X"
4106 PRINT "PROJECT FOUR-----+"
4110 FOR X=0 TO P9
4112 IF P9=0 THEN 4198
4115 FOR R=R1 TO R2 STEP I
4120 LET Q1=V(X,R)
4140 IF Q1<Q3 THEN 4180
4160 IF Q1>Q4 THEN 4190
4165 GO TO 4195
4180 LET Q3=Q1
4185 GO TO 4160
4190 LET Q4=Q1
4195 NEXT R
4198 NEXT X
4199 GO TO 4500
4500 LET Q5=Q4-Q3
4510 LET Q6=Q5/60
4520 PRINT TAB(2);Q3;TAB(17);Q3+(15*Q6);TAB(32);Q3+(30*Q6);
4521 PRINT TAB(47);Q3+(45*Q6);TAB(60);Q4
4525 PRINT TAB(5);"V";TAB(20);"V";TAB(35);"V";TAB(50);"V";
4526 PRINT TAB(65);"V"
4550 FOR X=1 TO 4
4555 FOR R=R1 TO R2 STEP I
4560 LET A(X,R)=INT((V(X,R)-Q3)/Q6)+5
4565 NEXT R
4570 NEXT X
4990 FOR P=0 TO R2
4992 IF A(1,P)=0 THEN 5910
4995 PRINT P;
5000 REM ******** PLOT SORT SUBROUNTIE
5010 IF A(1,P)>A(2,P) THEN 5300
5020 IF A(1,P) >A(3,P) THEN 5500
5030 IF A(1,P)>A(4,P) THEN 5700
5040 GOSUB 5981
5050 IF A(2,P)> A(3,P) THEN 5200
5060 IF A(2,P) > A(4,P) THEN 5150
5080 IF A(3,P)>A(4,P)THEN 5100
5090 GO SUB 5987
5091 GOSUB 5997
5095 GO TO 5999
5100 GO SUB 5989
5101 GOSUB 5995
5102 REM END OF W-X-Z-Y
5105 GO TO 5999
5150 GOSUB 5989
5151 GOSUB 5984
5152 GOSUB 5995
5154 REM END OF W-Z-X-Y
5155 GO TO5999
5200 REM KNOWN ORDER W SMALLEST X>Y
5210 IF A(3,P) >A(4,P) THEN 5250
5211 REM W SMALLEST Y (2ND)
5212 GOSUB 5987
5215 IF A(2,P)>A(4,P) THEN 5275
5225 GOSUB 5984
5226 GOSUB 5997
5230 GO TO 5999
5250 REM
5251 GOSUB 5989
5252 GOSUB 5987
5253 GO SUB 5993
5255 GO TO 5999
5275 REM W-Y-Z-X
5276 GOSUB 5989
5277 GOSUB 5993
5280 GO TO 5999
5300 REM KNOWN W>X
5310 IF A(2,P) >A(3,P) THEN 5500
5320 IF A(2,P)> A(4,P) THEN 5700
5325 REM X IS SMALLEST
5330 GOSUB 5983
5340 IF A(1,P)>A(3,P) THEN 5400
5350 IF A(1,P)>A(4,P) THEN 5390
5355 REM W(P) 2ND SMALL
5356 GOSUB 5981
5360 IF A(3,P)>A(4,P) THEN 5380
5370 REM
5371 GOSUB 5987
5372 GOSUB 5997
5375 GO TO 5999
5380 REM
5381 GOSUB 5989
5382 GOSUB 5995
5385 GO TO 5999
5390 REM
5392 GOSUB 5989
5394 GOSUB 5981
5396 GOSUB5995
5398 GO TO 5999
5400 REM X-?-?-? W>Y
5410 IF A(3,P)>A(4,P) THEN 5450
5411 REM X-Y-?-?
5412 GOSUB 5987
5420 IF A(1,P)>A(4,P) THEN 5475
5426 GOSUB 5981
5427 GOSUB 5997
5430 GO TO 5999
5450 REM
5455 GOSUB 5989
5460 GOSUB 5987
5465 GOSUB 5991
5470 GO TO 5999
5475 REM X-Y-Z-W
5476 GOSUB 5989
5477 GOSUB 5991
5480 GO TO 5999
5500 IF A(3,P)>A(4,P) THEN 5700
5505
5510 GOSUB 5987
5520 IF A(1,P)>A(2,P) THEN 5625
5530 IF A(1,P)>A(4,P) THEN 5585
5540 GOSUB 5981
5550 IF A(2,P)> A(4,P) THEN 5575
5560 REM Y-W-X-Z
5565 GOSUB 5984
5567 GOSUB 5997
5570 GO TO 5999
5575 REM Y-W-Z-X
5576 GOSUB 5989
5578 GOSUB 5993
5580 GOTO 5999
5585 REM
5586 GOSUB 5989
5587 GOSUB 5981
5588 GOSUB 5993
5590 GO TO 5999
5625 REM
5630 IF A(2,P)> A(4,P)THEN 5675
5635 GOSUB 5984
5640 IF A(1,P)>A(4,P)THEN 5650
5641 REMY-X-W-Z
5642 GOSUB5981
5644 GOSUB 5997
5646 GOTO 5999
5650 REM Y-X-Z-W
5652 GOSUB 5989
5654 GOSUB 5991
5660 GO TO 5999
5675 REM Y-Z-X-W
5677 GOSUB 5989
5679 GOSUB 5984
5681 GOSUB 5991
5685 GO TO 5999
5700 GOSUB 5989
5710 IF A(1,P)>A(2,P) THEN 5825
5720 IF A(1,P)>A(3,P) THEN 5790
5730 GOSUB 5981
5740 IF A(2,P)>A(3,P) THEN 5770
5750 REM Z-W-X-Y
5755 GOSUB 5984
5760 GOSUB 5995
5765 GO TO 5999
5770 REM Z-W-Y-X
5775 GOSUB 5987
5780 GOSUB 5993
5785 GO TO 5999
5790 REM Z-Y-W-X
5795 GOSUB 5987
5800 GOSUB 5981
5805 GOSUB 5993
5810 GO TO 5999
5825 REM Z-?-?-? W>X
5835 GOSUB 5984
5840 IF A(1,P)>A(3,P) THEN 5865
5845 REM Z=X-W-Y
5850 GOSUB 5981
5855 GOSUB 5995
5860 GO TO 5999
5865 REM Z-X-Y-W
5870 GOSUB 5987
5875 GOSUB 5991
5880 GO TO 5999
5885 REM Z-Y-X-W
5890 GOSUB 5987
5895 GOSUB 5984
5900 GOSUB 5991
5905 GO TO 5999
5910 IF A(2,P)=O THEN5940
5915 GO TO 5000
5940 PRINT P
5950 GO TO 5999
5980 REM **********PRINT STATEMENTS PLOT SORT SUBROUTINE****
5981 PRINT TAB (A(1,P))"*";
5982 RETURN
5983 REM
5984 PRINT TAB (A(2,P))".";
5985 RETURN
5987PRINT TAB (A(3,P))"X";
5988 RETURN
5989 PRINT TAB(A(4,P))"+";
5990 RETURN
5991 PRINT TAB (A(1,P))"*"
5992 RETURN
5993 PRINT TAB (A(2,P))"."
5994 RETURN
5995 PRINT TAB (A(3,P))"X"
5996 RETURN
5997 PRINT TAB(A(4,P))"+"
5998 RETURN
5999 NEXT P
6000 STOP
7000 REM IF A SINGLE DISCOUNT RATE
7010 FOR X=1 TO 4
7011 PRINT
7012 PRINT
7014 PRINT "**************PROJECT";X;"*****************************"
7016 PRINT "DISCOUNT RATE";TAB(30);"PRESENT VALUE";TAB(50);"TERMINAL VALUE"
7018 PRINT "-------------"; TAB(30)"-------------";TAB(50);"--------------"
7035 LET V(X,R)=T(X,R)=0
7040 FOR P=0 TO Y(X)-1
7055 LET H1 =Y(X)-(P+1)
7056 IF B(X,P)<0 THEN7080
7080 LET V(X,R)=V(X,R)+(B(X,P)*(1+(R/100))^(-P))
7100 NEXT P
7105 PRINT TAB(5);R;"%";TAB(35);V(X,R);TAB(55);T(X,R)+B(X,0)
7125 IF X>=P9 THEN 7500
7140 NEXT X
7500 REM SINGLE DISCOUNT COMPARISON SUBROUTINE
7502 LET Y(5)=Y(2)-Y(1)
7503 LET Y(6)=Y(3)-Y(1)
7504 LET Y(7)=Y(4)-Y(1)
7505 LET Y(8)=Y(3)-Y(2)
7506 LET Y(9)=Y(4)-Y(2)
7507 LET Y(10)=Y(4)-Y(3)
7510 IF Y(1)=Y(2) THEN 7600
7512 LET N=2
7520 FOR X=N TO P9+1
7522 IF X=P9+1 THEN 7580
7525 GOSUB 3023
7550 LET Z(X+3,R)=((T(X,R)+B(X,O))/(T(1,R)+B(1,0)))^(1/Y(X+3))-1
7560 PRINT TAB(7);R;"%";TAB(45);Z(X+3,R)*100;"%"
7580 NEXT X
7590 GO TO 7700
7600 IF Y(1)=Y(3) THEN 7650
7610 LET N=3
7620 GO TO 7520
7650 IF Y(1)=Y(4) THEN7999
7655 LET N=4
7660 GO TO 7520
7700 IF Y(2)=Y(3) THEN 7800
7705 LET N=3
7710 FOR X=N TO P9
7720 GOSUB 3220
7725 LET Z(X+5,R)=((T(X,R)+B(X,O))/(T(2,R)+B(2,0)))^(1/Y(X+5))-1
7730 PRINT TAB(7);R;"%";TAB(45);Z(X+5,R)*100;"%"
7740 NEXT X
7745 GO TO 7900
7800 IF Y(2)=Y(4) THEN 7999
7810 LET N=4
7820 GO TO 7710
7900 IF Y(3)=Y(4) THEN 7999
7910 GOSUB 3420
7950 LET Z(10,R)=((T(X,R)+B(X,0))/(T(3,R)+B(3,0)))^(1/Y(10))-1
7960 PRINT TAB(7);R;"%"; TAB(45); Z(10,R)*100;"%"
7999 GO TO 6000
9999 END