program PYMT; var I,PV,Y,IDIVN,t,t1 : longreal; N,M,k : integer; begin writeln('Interest Calculator'); writeln; writeln('Computes payment, present value, or # of payments when given'); writeln('annual interest rate, # of pymts/year, and two of the above.'); writeln; repeat write('Enter annual interest rate (00.0) and (I<1.0); writeln; repeat write('Enter # of payments/year (00) and (N<=365); writeln; repeat writeln('Enter two of the following, use zero for the other.'); writeln; repeat Write('Enter the present value: '); readln(PV); until PV>=0.0; repeat write('Enter amount of each payment: '); readln(Y); until Y>=0.0; repeat write('Enter # of payments: '); readln(M); until M>=0; k := 0; if PV=0.0 then k := k+1; if Y=0.0 then k := k+1; if M=0 then k := k+1; until k=1; IDIVN := I / FLOAT(N); writeln; if M=0 then begin M := -TRUNC((ln(1.0 - IDIVN*PV/Y)/ln(1.0+IDIVN) - 1.0)); Writeln('The number of payments is ',M,'.'); end {if} else begin t1 := IDIVN+1.0; t := t1; for k:=2 to M do t := t*t1; t := 1.0-(1.0/t); end; {else} if PV=0.0 then begin PV := Y*t/IDIVN; writeln('The present value is $',PV:4:2); end; {if} if Y=0.0 then begin Y := PV*IDIVN/t; writeln('The payments will each be $',Y:4:2); end; {if} end. {pymt}