[SLUG] project
Bob Garrood
bgarrood at tiscali.co.uk
Fri Jun 9 09:56:51 BST 2006
Hi
I've had a look at awk, which is actually quite a language. The GNU Gawk
manual runs to 214 pages. It's described as quick and dirty (well that works
for Bill Gates), and you can do all sorts with it.
For example, to print out the fixed monthly payment for a given loan, over a
given number of years at a fixed annual rate you would need a file like this
(payment.awk):
# A is for amount borrowed, n for number of years and i the annual interest
rate.
m=n*12
r=(1+i/1200)
p=A*r^(m-1)*(r-1)/(r^m-1)
{print p}
# This assumes that the rate charged per month is 1/12th the annual interest
rate, which may not now be true.
Then type something like: awk -f payment.awk A=2500000 n=10 r=5
You need to do <return>, to get the monthly payment, as awk is waiting for
input and Ctrl D (or whatever your EOF is) to stop it waiting.
You can put all this on a command line, but it needs a file if you want to
pretty it up and extend it. I will have to check the formula, which I haven't
used for a while.
Bob
More information about the Scarborough
mailing list