[SLUG] Re:project
Bob Garrood
bgarrood at tiscali.co.uk
Sat Jun 17 10:00:30 BST 2006
Hi
This awk program allows you to work out how long it would take to pay off a
loan, given the amount borrowed a, the payment per month p and the annual
percentage rate i. It has no error checking. The figures a,p and i go in a
file-MTime.txt like this:
100000 1000 5
The program MTime.awk is:
#gives an idea of time it takes to pay a loan at given payment and interest
BEGIN {print " Year", " Month"," Debt"}
{a=$1
p=$2
i = $3
r=(1+i/100)^(1/12)
print a,p,i,r}
{while ((a-p)>0)
{a = a*r-p
++m
if (m==12) {++y
m=0}
print " ",y," ", m," ", a
i=0
while (i<1000000) { ++i }}
}
The program is run with: awk -f MTime.awk MTime.txt
I'm sure there are better ways to do this.
Bob
More information about the Scarborough
mailing list