5 CLS
10 PRINT "     RATE OF RETURN - VARIABLE INFLOW"
20 PRINT 
30 PRINT "THIS PROGRAM WILL CALCULATE THE RATE OF RETURN OF AN 
40 PRINT "INVESTMENT COSTING A$ NOW AND RETURNING A(I)$ IN YEAR I
50 PRINT "WITH THE A(I)'S NOT NECESSARILY EQUAL AND NOT NECESSARILY
60 PRINT "POSITIVE.
70 PRINT "INPUT IS THE INITIAL INVESTMENT AND THE YEARLY DOLLAR RETURNS.
80 PRINT 
90 INPUT "PRESS ENTER TO BEGIN.";Z9
100 CLS
105 I=0
110 DIM A(100)
115 PRINT
120 INPUT "INITIAL INVESTMENT ";A(0)
125 A(0)=-A(0)
130 PRINT "RETURN YEAR ";I + 1;" (99999 TO END)";:INPUT A(I+1)
140 IF A(I+1) = 99999 GOTO 160
145 I=I+1
150 GOTO 130
160 R=0
170 JUMP=.1
174 JN=0: REM JN= NUMBER OF PASSES SO FAR
175 P=0
180 FOR K=0 TO I:P=P+A(K)/(1+R)[K:NEXT K
190 IF ABS(P) < .5 GOTO 400
200 IF P>0 GOTO 300
210 R=R-JUMP
220 JUMP = JUMP/10
230 GOTO 300
300 R=R+JUMP
305 PRINT @ 40,"PASS ";JN;"  R=";100*R:JN=JN+1:JN=JN+1
310 GOTO 175
400 REM PRINTING SUBROUTINE
410 PRINT
415 CLS
420 PRINT "RATE OF RETURN IS ";100*R;" %"
430 END
