Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0020/bnksim.bnk
There are 2 other files named bnksim.bnk in the archive. Click here to see a list.
2' NAME--BANKSIM
4' 
6' DESCRIPTION
7' THIS PROGRAM WILL SIMULATE ONE YEAR'S ACTIVITIES OF A SMALL
8' BANK USING PROBABILITIES FOR WITHDRAWALS AND DEPOSITS.  IT
9' ASSUMES THESE WITHDRAWALS AND DEPOSITS ARE NORMALLY DISTRIBUTED.
10' THIS BANK WILL BE OPEN 20 DAYS AMONTH, WITH INTEREST COMPUTED
11' QUARTERLY ON THE MINIMUM BALANCE; THIS PROGRAM WILL PRODUCE
12' MONTHLY, QUARTERLY, AND YEARLY STATEMENTS.
14'
16' SOURCE--REVISED 8/8/69 BY J. ROKUS
18'
20' INSTRUCTIONS
21' THERE IS SAMPLE DATA IN LINES 3000-3004.  IF YOU WISH TO USE
22' YOUR OWN BEGINNING BALANCES, INSERT THEM INTO THESE DATA
23' STATEMENTS.  BE SURE TO INDICATE HOW MANY CUSTOMERS YOU ARE
24' USING WHEN ASKED DURING THE RUN.  TYPE 1 WHEN THE COMPUTER
25' ASKS YOU WHICH TYPE OF DATA YOU WISH TO USE.
26' THE ACTUAL SIMULATION BEGINS IN LINE 540.
28'
30' THIS PROGRAM WAS WRITTEN FOR STUDENT USE AT AMOS TUCK SCHOOL
32' OF HANOVER, N.H. WHICH DOES NOT ASSUME RESPONSIBILITY FOR ITS
34' ACCURACY.
40'
50' * * * * * * * * * * MAIN PROGRAM * * * * * * * * * * * * * * 
60'
91 PRINT"IN THIS PROGRAM YOU HAVE YOUR CHOICE OF THE TYPE OF DATA TO USE."
92 PRINT"BY ENTERING THE NUMBER  1  ,THE COMPUTER WILL BEGIN ALL"
93 PRINT"BALANCES AT $100. IN THIS MANNER THE USER CAN SEE THE"
94 PRINT"EFFECTS MUCH EASIER ON THE ACCOUNT BALANCES FROM MONTH TO MONTH."
95 PRINT
96 PRINT"BY ENTERING THE NUMBER  2  , THE COMPUTER WILL SELECT LARGER"
97 PRINT"RANDOM NUMBERS FOR BEGINNING BALANCES."
98 PRINT
99 PRINT"WHICH METHOD DO YOU WANT TO USE";
100 INPUT Z
101 PRINT
110 PRINT"HOW MANY CUSTOMERS DO YOU WISH TO USE IN THIS SIMULATION(LIMIT--"
120 PRINT "--250--FOR STORAGE PURPOSES.";
130 INPUT N
140 IF N<=250 THEN 170
150 PRINT"TOO MANY CUSTOMERS, TRY AGAIN."
160 GO TO 110
170 PRINT
180 PRINT "WHAT IS THE YEARLY INTEREST OF THIS BANK (PERCENTAGE FORMAT)";
190 INPUT R
200 LET R=R/100
230 PRINT
240 PRINT"WHAT IS THE PROBABILITY OF A CUSTOMER ENTERING THE BANK DURING"
250 PRINT"ONE MONTH?  THE BANK IS OPEN 20 DAYS PER MONTH.(E.G.,2 DAYS OUT"
260 PRINT"OF 20 = .10 PROBABILITY)";
270 INPUT E
280 IF E <= 1 GO TO 310
290 PRINT"PROBABILITY NOT ENTERED CORRECTLY; TRY AGAIN."
300 GO TO 240
310 PRINT
320 PRINT"WHAT IS THE MEAN TRANSACTION FOR EACH PERSON ENTERING--IN"
330 PRINT"DOLLARS--ASSUMING ALL DEPOSITS AND WITHDRAWALS HAVE THE SAME"
340 PRINT"MEAN";
350 INPUT M
360 PRINT
370 PRINT"WHAT IS THE STANDARD DEVIATION--IN DOLLARS";
380 INPUT S
390 PRINT
400 PRINT"WHAT IS THE PROBABILITY THAT, WHEN A  CUSTOMER ENTERS THE "
410 PRINT "BANK, HE WILL WITHDRAW MONEY";
420 INPUT T
430 IF T <=.99 GO TO 460
440 PRINT"YOU HAVE ENTERED THE PROBABILITY INCORRECTLY; TRY AGAIN."
450 GO TO 400
460 PRINT
470 PRINT
480 PRINT"**PROBLEM:TO SIMULATE BANK ACTIVITIES USING";N;"CUSTOMERS,"
490 PRINT"WITH THE BANK HAVING A";R;"YEARLY RATE."
500 PRINT"P(WITHDRAWAL/ENTRY INTO BANK) IS";E;"WITH THE MEAN TRANSACTION"
510 PRINT"BEING $";M;"AND THE STANDARD DEVIATION BEING $";S
520 PRINT
530 PRINT
535 REM     THE SIMULATION PROCEDURE ACTUALLY BEGINS HERE......
540 DIM A(250),M(250),Z(250)
550 LET P=Q=0
560 DEF FNN(M,S)=COS(6.28138*RND)*S*SQR(-2*LOG(RND))+M
570 FOR I = 1 TO N
580 IF Z=1 THEN 610
590 LET A(I)=RND*1000
600 GO TO 620
610 READ A(I)
620 LET M(I)=A(I)
630 NEXT I
640 PRINT "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * "
650 PRINT
660 PRINT
670 PRINTTAB(10);"THE NUMBERS TO BE USED AS BEGINNING BALANCES FOR THE"
680 PRINTTAB(30);"ACCOUNTS ARE"
690 PRINT
700 PRINT
710 PRINT"CUSTOMER";TAB(16);"BALANCE";TAB(43);"CUSTOMER";TAB(59);"BALANCE"
720 FOR I = 1 TO INT(N/2+.5)
725 LET X1=A(I+(INT(N/2+.5)))
726 LET V=FNF(A(I),10,2)
727 CHANGE V TO V$
730 PRINT I;TAB(12),V$," ",I+INT(N/2+.5);
733 LET V=FNF(X1,10,2)
734 CHANGE V TO V$
735 PRINT TAB(55);V$
740 LET Q=Q+A(I)+A(I+(INT(N/2+.5)))
750 NEXT I
780 PRINT
788 LET V=FNF(Q,10,2)
789 CHANGE V TO V$
790 PRINT "TOTAL BEGINNING BALANCES";V$
800 PRINT
810 FOR C = 1 TO 240    'C IS THE NUMBER OF DAYS THE BANK IS OPEN
820 GO TO 920
830 IF C/60 = INT(C/60) THEN 1070   'DETERMINING IF IT IS A QUARTER OR
840 IF C/20 = INT(C/20) THEN 1170    'A MONTH
850 NEXT C
860 PRINTTAB(15);"THE FINAL ACCOUNT BALANCES FOR THE YEAR ARE"
870 PRINT
880 PRINT
890 PRINT"CUSTOMER";TAB(16);"BALANCE";TAB(43);"CUSTOMER";TAB(59);"BALANCE"
900 GOSUB 1210
910 STOP
920 FOR I = 1 TO N
930 IF RND<=E THEN 960
931 REM     THE COMPUTER IS GENERATING RANDOM NUMBERS AND CHECKING THEM
932 REM     AGAINST THE VALUE OF E--THE PROBABILITY OF A CUSTOMER
933 REM     ENTERING THE BANK.  IF HE DID ENTER(IF THE SELECTED VALUE
934 REM     IS LESS THAN E), THE COMPUTER THEN DETERMINES IF THE PERSON
935 REM     WITHDREW ANY MONEY.  IT DOES THIS IN THE SAME MANNER. 
936 REM     THE COMPUTER SELECTS A RANDOM NUMBER AND COMPARES IT
937 REM     WITH T--THE P(WITHDRAW/ENTER THE BANK).
940 NEXT I
950 GO TO 830
960 IF RND<= T THEN 1000
970 LET D = FNN(M,S)
980 LET A(I)=A(I)+D
990 GO TO 940
1000 LET W = FNN(M,S)
1010 LET A(I)=A(I)-W    'SUBTRACTING THE WITHDRAWAL FROM THE BALANCE.
1020 IF A(I)>0 THEN 1040
1021 REM     IF THE WITHDRAWAL IS LARGER THAN THE BALANCE, THE PERSON
1022 REM     WILL ONLY WITHDRAWAL THE MONEY HE HAS IN HIS ACCOUNT.
1023 REM     HIS ACCOUNT WILL THEN BE ZERO.
1030 LET A(I)= 0
1040 IF A(I)>M(I) THEN 940
1050 LET M(I)=A(I)
1060 GO TO 940
1070 PRINTTAB(31);"QUARTER";C/60
1075 PRINT
1080 PRINT"CUSTOMER";TAB(16);"BALANCE";TAB(30);"INTEREST"
1090 FOR I = 1 TO N
1100 LET Z(I)=R/4*M(I)
1101 REM     THE INTEREST WAS JUST CALCULATED.
1110 LET P = P + Z(I)
1120 LET A(I)=A(I)+Z(I)
1130 LET M(I)=A(I)
1140 NEXT I
1150 GOSUB 1340
1160 GO TO 850
1170 PRINTTAB(31);"MONTH";C/20
1175 PRINT
1180 PRINT"CUSTOMER";TAB(16);"BALANCE";TAB(43);"CUSTOMER";TAB(59);"BALANCE"
1190 GOSUB 1210
1200 GO TO 850
1210 LET A5 = 0
1220 FOR I = 1 TO INT(N/2+.5)
1230 LET A5=A5+A(I+(INT(N/2+.5)))+A(I)
1233 LET X5=INT(100*(A(I)+.005))/100
1236 LET X6=INT(100*(A(I+(INT(N/2+.5)))+.005))/100
1238 LET V=FNF(X5,10,2)
1239 CHANGE V TO V$
1240 PRINT I;TAB(12);V$," ",
1250 PRINT I+(INT(N/2+.5));
1253 LET V=FNF(X6,10,2)
1254 CHANGE V TO V$
1255 PRINT TAB(55);V$
1260 NEXT I
1290 PRINT
1298 LET V=FNF(A5,10,2)
1299 CHANGE V TO V$
1300 PRINT "TOTAL";V$
1310 PRINT
1320 PRINT
1330 RETURN
1340 LET A6 = 0
1350 FOR I = 1 TO N
1360 LET A6=A6+A(I)
1365 LET X3=INT(100*(A(I)+.005))/100
1368 LET V=FNF(X3,10,2)
1369 CHANGE V TO V$
1370 PRINT I;TAB(12);V$;
1373 LET V=FNF(Z(I),10,2)
1374 CHANGE V TO V$
1375 PRINT TAB(26);V$
1380 NEXT I
1390 PRINT
1398 LET V=FNF(A6,10,2)
1399 CHANGE V TO V$
1400 PRINT "TOTAL IN BANK      ";V$
1408 LET V=FNF(P,10,2)
1409 CHANGE V TO V$
1410 PRINT "TOTAL CUMULATIVE INTEREST";V$
1420 PRINT
1430 PRINT
1440 RETURN
2000 DEF FNF(X9,W9,D9)
2010 DIM P(25)
2020 LET P9=INT(ABS(X9)*10^D9+.5)
2030 IF P9<10^(W9-1) THEN 2060
2040 LET FNF=X9
2050 GOTO 2280
2060 FOR P8=W9 TO W9-D9+1 STEP -1
2070 LET P(P8)=P9-10*INT(P9/10)+48
2080 IF P(P8)<58 THEN 2100
2090 LET P(P8)=0
2100 LET P9=INT(P9/10)
2110 NEXT P8
2120 LET P(W9-D9)=46
2130 FOR P8=W9-D9-1 TO 1 STEP -1
2140 LET P(P8)=P9-10*INT(P9/10)+48
2150 IF P(P8)<58 THEN 2170
2160 LET P(P8)=0
2170 LET P9=INT(P9/10)
2180 IF P9=0 THEN 2200
2190 NEXT P8
2200 IF X9>=0 THEN 2230
2210 LET P(P8-1)=45
2220 LET P8=P8-1
2230 FOR P8=P8-1 TO 1 STEP -1
2240 LET P(P8)=32
2250 NEXT P8
2260 LET P(0)=W9
2270 LET FNF=P
2280 FNEND
3000 DATA 100,100,100,100,100,100,100,100,100,100,100,100,100,100
3001 DATA 100,100,100,100,100,100,100,100,100,100,100,100,100,100
3002 DATA 100,100,100,100,100,100,100,100,100,100,100,100,100,100
3003 DATA 100,100,100,100,100,100,100,100
9999 END