Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0025/annuit.bas
There are 2 other files named annuit.bas in the archive. Click here to see a list.
2	PRINT "A N N U I T Y   C A L C U L A T I O N"
3	PRINT
4	PRINT "   WANT INSTRUCTIONS FIRST (1=YES, 2=NO)";
5	INPUT L
6	IF L<>1 THEN 8
7	GOSUB 400
8	LET S=0
9	PRINT
10	PRINT "WHICH ANNUITY TYPE (1=PAYMENT, 2=WITHDRAWAL)";
30	INPUT A
32	GOTO 40
33	IF A=1 THEN 38
34	LET  A=1
35	GOTO 40
38	LET  A=2
40	IF  A=1 THEN 95
50	IF A=2 THEN 547
55	PRINT
60	PRINT "   ANSWER 1 OR 2 PLEASE."
70	GOTO 9
95	IF S=1 THEN 115
97	PRINT
100	PRINT "WHICH VARIABLE IS UNKNOWN (1=N,2=A,3=I,4=R)";
110	INPUT D
115	IF D=1 THEN 157
120	IF D=2 THEN 195
130	IF D=3 THEN 245
140	IF D=4 THEN 257
145	PRINT
150	PRINT "   ANSWER 1,2,3,OR 4 PLEASE."
155	GOTO 97
157	PRINT
160	PRINT "WHAT ARE A($),I(PCT),R($)";
170	INPUT A1,I1,R1
171	LET I1=I1/100
172	LET N1=LOG((A1*I1/R1)+1)/LOG(1+I1)
175	PRINT
180	PRINT "NUMBER OF PERIODS = N =";N1
190	GOTO 495
195	PRINT
200	PRINT "WHAT ARE N(INTEGER),I(PCT),R($)";
210	INPUT N1,I1,R1
215	LET I1=I1/100
220	LET A1=R1*((1+I1)^N1-1)/I1
225	PRINT
230	PRINT "AMOUNT AT END OF N PERIODS = A =";A1
240	GOTO 495
245	PRINT
250	PRINT "WHAT ARE N(INTEGER),A($),R($)";
255	GOTO 845
257	PRINT
260	PRINT "WHAT ARE N(INTEGER),A($),I(PCT)";
265	INPUT N1,A1,I1
267	LET I1=I1/100
268	LET R1=A1*I1/((1+I1)^N1-1)
269	PRINT
270	PRINT "PAYMENT EACH PERIOD = R =";R1
280	GOTO 495
400	PRINT
402	PRINT "THIS PROGRAM PERFORMS CALCULATIONS FOR"
405	PRINT "BOTH PAYMENT AND WITHDRAWAL ANNUITIES."
410	PRINT
415	PRINT "VARIABLES ARE DENOTED AS FOLLOWS:"
420	PRINT
425	PRINT "   N = NUMBER OF PERIODS"
430	PRINT "   P = ORIGINAL PRINCIPAL AMOUNT"
435	PRINT "   A = TOTAL AMOUNT AT END OF N PERIODS"
440	PRINT "   I = INTEREST RATE PER PERIOD, IN PERCENT"
445	PRINT "   R = AMOUNT OF PAYMENT/WITHDRAWAL EACH PERIOD"
450	PRINT
455	PRINT "FOR A PAYMENT ANNUITY, YOU MAY GIVE ANY"
460	PRINT "  THREE OF N,A,I,R AND FIND THE FOURTH."
462	PRINT
465	PRINT "FOR A WITHDRAWAL ANNUITY, YOU GIVE ANY"
470	PRINT "  THREE OF N,P,I,R AND FIND THE FOURTH."
471	PRINT
472	PRINT "NOTE: FOR LOAN OR MORTGAGE, USE THE"
473	PRINT "      WITHDRAWAL ANNUITY OPTION."
475	PRINT
476	PRINT "AFTER EACH CASE, YOU MAY CHOOSE ONE"
477	PRINT "OF THE FOLLOWING ALTERNATIVES:"
478	PRINT
480	PRINT "   1 = ANOTHER CASE, SAME UNKNOWN VARIABLE"
481	PRINT "   2 = ANOTHER CASE, DIFFERENT UNKNOWN"
482	PRINT "   3 = ANOTHER CASE, OTHER TYPE OF ANNUITY"
483	PRINT "   4 = TOTAL INTEREST PAID OVER N PERIODS"
484	PRINT "   5 = TABLE OF WITHDRAWALS, PRINCIPAL, AND INTEREST"
485	PRINT "   6 = STOP THE PROGRAM"
489	PRINT
490	RETURN
495	PRINT
497	PRINT "ANOTHER CASE (TYPE CODE NUMBER)";
500	INPUT S
510	IF S=1 THEN 40
515	IF S=2 THEN 40
516	IF S=6 THEN 995
519	IF S=3 THEN 33
520	IF A<>1 THEN 524
521	PRINT
522	PRINT "ALTERNATIVE NOT APPLICABLE TO PAYMENT ANNUITIES."
523	GOTO 495
524	IF S=4 THEN 634
525	IF S=5 THEN 634
547	IF S=1 THEN 570
550	PRINT
555	PRINT "WHICH VARIABLE IS UNKNOWN (1=N,2=P,3=I,4=R)";
560	INPUT A1
570	IF A1=1 THEN 600
575	IF A1=2 THEN 815
580	IF A1=3 THEN 840
585	IF A1=4 THEN 970
589	PRINT
590	PRINT "   ANSWER 1,2,3, OR 4 PLEASE."
595	GOTO 560
600	PRINT
601	PRINT "WHAT ARE P($),I(PCT),R($)";
610	INPUT P1,I1,R1
615	LET I1=I1/100
620	LET N1=LOG(R1/(R1-P1*I1))/LOG(1+I1)
625	PRINT
630	PRINT "NUMBER OF PERIODS = N =";N1
632	GOTO 495
634	LET N1=N1+.00001
635	LET P2=INT(N1)-N1
640	IF ABS(P2)>.00001 THEN 660
650	LET N1=N1-1
651	GOTO 680
660	LET N1=INT(N1)
680	LET P2=1
690	IF S=4 THEN 707
692	IF S=5 THEN 703
703	LET P2=0
705	PRINT 
706	PRINT "PERIOD","PRINCIPAL","INTEREST","PRINC BAL","INT TO DATE"
707	PRINT
708	PRINT " 0",P1
710	LET X=0
712	LET X9=P1
715	LET Y=0
720	FOR S=1 TO N1
725	LET A2=(R1-P1*I1)*(1+I1)^(S-1)
730	LET A2=.01*INT((100*A2)+.5)
735	LET B=.01*INT((100*(R1-A2)+.5))
740	LET X=X+A2
744	LET X9=.01*INT((100*(X9-A2)+.5))
745	LET Y=Y+B
750	IF P2 <>0 THEN 760
755	PRINT S,A2,B,X9,Y
760	NEXT S
765	LET S=N1+1
770	LET A2=P1-X
775	LET B=.01*INT((100*I1*(P1-X))+.5)
780	LET X=X+A2
782	LET X9=0
785	LET Y=Y+B
786	IF P2=0 THEN 790
787	PRINT "TOTAL INTEREST PAID =";Y
788	GOTO 495
790	PRINT S,A2,B,X9,Y
792	GOTO 495
815	PRINT
816	PRINT "WHAT ARE N(INTEGER),I(PCT),R($)";
820	INPUT N1,I1,R1
822	LET I1=I1/100
825	LET P1=R1*((1+I1)^N1-1)/(I1*(1+I1)^N1)
829	PRINT
830	PRINT "ORIGINAL PRINCIPAL AMOUNT IS";P1
835	GOTO 495
840	PRINT
841	PRINT "WHAT ARE N(INTEGER),P($),R($)";
845	INPUT N1,P1,R1
847	PRINT
865	LET I1 = .1
867	LET I2=.05
870	LET P4=P1
875	LET P3=P1
880	IF SGN (P1-P4)=SGN(P1-P3) THEN 888
882	LET I2=I2/2
888	LET P4=P3
889	IF A=1 THEN 892
890	LET I1=I1+SGN(P3-P1)*I2
891	GOTO 893
892	LET I1=I1+SGN(P1-P3)*I2
893	IF I2<I1/3 THEN 895
894	LET I2=.2*I1
895	LET P3=R1*((1+I1)^N1-1)/I1
896	IF A=1 THEN 898
897	LET P3=P3/((I1+1)^N1)
898	REM
900	IF ABS((P3-P1)/(P1+1E-8))>1E-7 THEN 880
905	PRINT "INTEREST PER PERIOD (PCT) = I = "; 100*I1
910	GOTO 495
970	PRINT
972	PRINT "WHAT ARE N(INTEGER),P($),I(PCT)";
975	INPUT N1,P1,I1
977	LET I1=I1/100
980	LET R1=P1*I1*(1+I1)^N1/((1+I1)^N1-1)
985	PRINT
987	PRINT "WITHDRAWAL EACH PERIOD = R =";R1
990	GOTO 495
995	END