I had an assignment to:

1. write a program that prompts the user for the amount of laon, length of

loan in years, low interest rate and a high interest rate.

2. Print out monthly payment for teh different interest rates from low to

high, incremented by 0.25%

3. Make use of power calculations

4. Use a repeat loop to solve the problem.

I've encountered this error in the following program:

RunTimer Error 205

which the help file says is a Floating Point Overflow, where the number is

to big.

I've figured out the line with the problem, but I can't figure out how to

fix it.

It only occurs with higher number of years (30 did it). I can get it to

work fine with smaller time periods.

Any help would be appreciated.

program Loan;

uses WinCRT; {just change this line to run it in DOS Turbo Pascal or

Macintosh Think Pascal}

var

p,k,n,c,a,y,t,h,l : real;

{principal, monthly rate, number of payments, (1 + k)^n}

{monthly payment, years, temp rate, high rate, and low rate,}

function power(B,E:real):real;

begin {power}

power:=exp(E*ln(B)); {THIS IS THE LINE WITH THE ERROR}

end; {power}

begin {main}

writeln('Welcome to the Financial Loan Analyzer');

writeln;

writeln('In order to calculate your monthly payment options,');

writeln('I''ll need three pieces of information.');

writeln('Please enter each one when prompted');

writeln;

write('Amount of Loan (Principal) : ');

readln(p);

writeln;

write('Number of Years before paying off Loan : ');

readln(y);

writeln;

write('Low Interest Rate of Loan : ');

readln(l);

writeln;

write('High Interest Rate of Loan : ');

readln(h);

writeln;

n := y * 12; {assign # of payments to years * 12}

t := l;

repeat

k := t / 12; {assign monthly rate to yearly / 12}

c := power(1+k,n); {do what the book tells me to do}

a := (p * k * c) / (c - 1); {assign a the monthly payment}

writeln('Interest Rate':20,'Monthly Payment':20);

writeln(t:20:2,a:20);

t:= t+0.25;

until t >= h;

end. {main}