loan amortization

S

Sirius

ok i decided to do a loan amortization program that will take, as
input, loan amount, loan length (in years) and annual interest rate.
I have done all the coding but when it comes to formulas I'm totally
lost. I need to display Interest, Principal, and Balance on month to
month bases. Like i said the code is all done...well all except the
math part and math has never been my strong side. you can see it on
my blog here: http://javacodee.blogspot.com/ any help is welcome....
 
R

Roedy Green

ok i decided to do a loan amortization program that will take, as
input, loan amount, loan length (in years) and annual interest rate.
I have done all the coding but when it comes to formulas I'm totally
lost. I need to display Interest, Principal, and Balance on month to
month bases.

Think first principles. all you need in the way of formulae is
interest = principal * rate.
Work out each month, and wrap into a loop. It only gets tricky if you
don't have a loop.
 
L

Lew

Roedy said:
Think first principles. all you need in the way of formulae is
interest = principal * rate.
Work out each month, and wrap into a loop. It only gets tricky if you
don't have a loop.

Beware round-off errors. Direct analytical computation might be more reliable
than looping, but numerics is a tricky area.

Google and Wikipedia will yield up the precise formulae right quickly.
 
G

Greg R. Broderick

ok i decided to do a loan amortization program that will take, as
input, loan amount, loan length (in years) and annual interest rate.
I have done all the coding but when it comes to formulas I'm totally
lost. I need to display Interest, Principal, and Balance on month to
month bases. Like i said the code is all done...well all except the
math part and math has never been my strong side. you can see it on
my blog here: http://javacodee.blogspot.com/ any help is welcome....

Google is your friend. Googling "amortization formula" should provide you
the information you require.

Regards

--
---------------------------------------------------------------------
Greg R. Broderick (e-mail address removed)

A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
 
P

Patricia Shanahan

Sirius said:
ok i decided to do a loan amortization program that will take, as
input, loan amount, loan length (in years) and annual interest rate.
I have done all the coding but when it comes to formulas I'm totally
lost. I need to display Interest, Principal, and Balance on month to
month bases. Like i said the code is all done...well all except the
math part and math has never been my strong side. you can see it on
my blog here: http://javacodee.blogspot.com/ any help is welcome....

I've taken a quick look at your code, and have a suggestion that may
help you.

Separate the calculation from the string parsing. Have a method that
calculates the monthly payment given loan amount, loan length, and
interest rate. Test that method, in isolation, feeding it easy data.

You can build test cases by picking the monthly payment, duration, and
interest rate, and calculating the loan amount working backwards month
by month from the zero final balance.

Patricia
 
S

Sirius

I've taken a quick look at your code, and have a suggestion that may
help you.

Separate the calculation from the string parsing. Have a method that
calculates the monthly payment given loan amount, loan length, and
interest rate. Test that method, in isolation, feeding it easy data.

You can build test cases by picking the monthly payment, duration, and
interest rate, and calculating the loan amount working backwards month
by month from the zero final balance.

Patricia

thanks everyone for your input i will take everything into
consideration
 
S

Sirius

thanks everyone for your input i will take everything into
consideration

hi all, i fot it to work now....it turns out that my formula for the
monthlyPaymnet wasn't correct and when i fixed that everything worked
out fine... thanks for everyone's help again
 
R

Roedy Green

Beware round-off errors.

If you use doubles, you have about 14 significant digits. Let's say
your are working on a $100,000.00 mortgage. That gives you 7 places
for fractions of a penny. Your loop will go no more than 50 years. So
I think it should be safe for a novice to close his eyes and ignore
roundoff errors.

When I worked for Univac back in the 1970s, I was dismayed to discover
that every financial institution in the USA computes interest a
different way, and that way is generally considered a secret. I
worked on a banking package called First/90 that allowed banks to plug
in their own interest-computing module, with no default.

I would hope by now consumer advocates would have managed to enforce a
uniform algorithm for both savings accounts and mortgages.

Einstein made a comment that the most powerful force in the universe
is compound interest. Sean B. Carroll in "the Making of the Fittest"
explains that the impressive results of evolution are based on a
similar compound interest effect. Even the tiniest compound interest
rate over time becomes enormous in effect.

Jesus and Mohammed railed against compound interest (called usury in
their time) knowing how over time it would tear the social fabric
apart by dividing society into extreme haves and have nots.
 
M

Michael Jung

Roedy Green said:
If you use doubles, you have about 14 significant digits. Let's say
your are working on a $100,000.00 mortgage. That gives you 7 places
for fractions of a penny. Your loop will go no more than 50 years. So
I think it should be safe for a novice to close his eyes and ignore
roundoff errors.

Depending on your customer, you'd better not do that. If you have different
programs (say legacy, when you are talking about 50 years) that slightly round
different at certain points, maybe used a different number of significant
digits, etc., you will find a whole bank looking for the missing penny.

An insurance company insider told me that they once spotted a penny difference
in calculations and a good part of the company went looking for it. It later
turned out that some ingenious technician (programmer?) booked fractions of
pennies of many transactions onto his account or the pennies, when there was a
full penny difference. Since a lot of accounts were involved, there was a
steady money flow (at the time of the tale the fraud suit was pending). The
insider also said that they wouldn't have made such a fuss, if this had
involved a million or so (probably tongue in cheek). [If you are an urban
legend/FOAF hunter: I have long lost contact with the man, so I can't prove
this anymore. It was in the late 80's.]

If, on the other hand, you are writing a program estimating your grandson's
dividend for certain saving plans, 14 digits should suffice.
When I worked for Univac back in the 1970s, I was dismayed to discover
that every financial institution in the USA computes interest a
different way, and that way is generally considered a secret. I
worked on a banking package called First/90 that allowed banks to plug
in their own interest-computing module, with no default.

I would hope by now consumer advocates would have managed to enforce a
uniform algorithm for both savings accounts and mortgages.

I don't know. Consider the legacy problem above. Banks and insurance companies
are very conservative.

Michael
 
R

RedGrittyBrick

Michael said:
An insurance company insider told me that they once spotted a penny difference
in calculations and a good part of the company went looking for it. It later
turned out that some ingenious technician (programmer?) booked fractions of
pennies of many transactions onto his account or the pennies, when there was a
full penny difference. Since a lot of accounts were involved, there was a
steady money flow (at the time of the tale the fraud suit was pending). The
insider also said that they wouldn't have made such a fuss, if this had
involved a million or so (probably tongue in cheek). [If you are an urban
legend/FOAF hunter: I have long lost contact with the man, so I can't prove
this anymore. It was in the late 80's.]

http://www.snopes.com/business/bank/salami.asp
 
M

Michael Jung

RedGrittyBrick said:
Michael said:
An insurance company insider told me that they once spotted a penny
difference
in calculations and a good part of the company went looking for it. It later
turned out that some ingenious technician (programmer?) booked fractions of
pennies of many transactions onto his account or the pennies, when there was a
full penny difference. Since a lot of accounts were involved, there was a
steady money flow (at the time of the tale the fraud suit was pending). The
insider also said that they wouldn't have made such a fuss, if this had
involved a million or so (probably tongue in cheek). [If you are an urban
legend/FOAF hunter: I have long lost contact with the man, so I can't prove
this anymore. It was in the late 80's.]
http://www.snopes.com/business/bank/salami.asp

Yes, I've thought such legends must exist in the wild. It doesn't say whether
some are true or not, though. Probably difficult to dis-/prove, unless
someone has access to DB queries on court records willing to search.

Michael
 
P

Patricia Shanahan

Michael said:
RedGrittyBrick said:
Michael said:
An insurance company insider told me that they once spotted a penny
difference
in calculations and a good part of the company went looking for it. It later
turned out that some ingenious technician (programmer?) booked fractions of
pennies of many transactions onto his account or the pennies, when there was a
full penny difference. Since a lot of accounts were involved, there was a
steady money flow (at the time of the tale the fraud suit was pending). The
insider also said that they wouldn't have made such a fuss, if this had
involved a million or so (probably tongue in cheek). [If you are an urban
legend/FOAF hunter: I have long lost contact with the man, so I can't prove
this anymore. It was in the late 80's.]

http://www.snopes.com/business/bank/salami.asp


Yes, I've thought such legends must exist in the wild. It doesn't say whether
some are true or not, though. Probably difficult to dis-/prove, unless
someone has access to DB queries on court records willing to search.

Michael

I was told the penny rounding story in 1970. I don't know whether it was
true or not.

Patricia
 
J

John W. Kennedy

Roedy said:
Jesus and Mohammed railed against compound interest (called usury in
their time) knowing how over time it would tear the social fabric
apart by dividing society into extreme haves and have nots.

Any interest, in fact. And the Torah and Aristotle also condemn it.
--
John W. Kennedy
"Those in the seat of power oft forget their failings and seek only the
obeisance of others! Thus is bad government born! Hold in your heart
that you and the people are one, human beings all, and good government
shall arise of its own accord! Such is the path of virtue!"
-- Kazuo Koike. "Lone Wolf and Cub: Thirteen Strings" (tr. Dana Lewis)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top