💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › Srcs › termloan.txt captured on 2024-06-16 at 14:28:05.

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

{
DISCLAIMER

Copyright (C) 1997 by Adrian Philip Whichello. All rights reserved.

I, Adrian Philip Whichello, MAKE NO WARRANTY ON THIS SOFTWARE, EITHER EXPRESS
OR IMPLIED, WITH RESPECT TO QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR
A PARTICULAR PURPOSE.

IN NO EVENT WILL I BE HELD RESPONSIBLE FOR DIRECT, INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OF THE SOFTWARE.

I RELEASE THIS PROGRAM AS FREEWARE. YOU MAY COPY, GIVE AWAY AND USE THIS
PROGRAM, PROVIDED THIS NOTICE REMAINS ATTACHED AT ALL TIMES.

}

program last_payment;
var
  ch : char;
  numpays, numyears : integer;
  principal, regpay, percent, rate, term, numpays1 : real;
  s : array [boolean] of string[1];
begin
  s[false] := '';
  s[true] := 's';
  writeln('Term of a Loan');
  repeat
    writeln;
    write('Regular payment: 


);
    readln(regpay);
    write('Principal: 


);
    readln(principal);
    write('Number of payments per year: ');
    readln(numpays);
    numpays1 := 1.0 / numpays;
    write('Annual Interest rate: (%) ');
    readln(percent);
    rate := 0.01 * percent * numpays1;
    term := -ln(1.0 - (principal * rate / regpay)) / ln(1.0 + rate) * numpays1;
    writeln;
    numyears := trunc(term);
    numpays := round(12.0 * (term - numyears));
    if numpays = 12 then begin
      numyears := numyears + 1;
      numpays := 0
    end;
    write('Term = ', numyears, ' years');
    if numpays > 0 then write(' and ', numpays, ' month', s[numpays > 1]);
    writeln;
    regpay := regpay * (12 * numyears + numpays);
    writeln('Total expenditure: 


, regpay:1:2,
                  ' (


, regpay / (numyears + numpays / 12.0):1:2, ' per year)');
    write('Another run ?');
    read(ch)
  until ch in ['N', 'n']
end.