Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

loan amortization

Thread view: 
Sirius - 08 Aug 2007 07:03 GMT
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....
Roedy Green - 08 Aug 2007 07:10 GMT
>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.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 08 Aug 2007 14:07 GMT
>> ok i decided to do a loan amortization program that will take, as
>> input, loan amount, loan length (in years) and annual interest rate.
[quoted text clipped - 6 lines]
> 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.

Signature

Lew

Roedy Green - 08 Aug 2007 18:28 GMT
>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.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 08 Aug 2007 22:52 GMT
> I would hope by now consumer advocates would have managed to enforce a
> uniform algorithm for both savings accounts and mortgages.

<http://en.wikipedia.org/wiki/Compound_interest>

Signature

Lew

Michael Jung - 09 Aug 2007 07:59 GMT
> >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.

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
[quoted text clipped - 4 lines]
> 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
RedGrittyBrick - 09 Aug 2007 10:40 GMT
> 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
[quoted text clipped - 6 lines]
> 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
Michael Jung - 09 Aug 2007 20:05 GMT
> > An insurance company insider told me that they once spotted a penny
> > difference
[quoted text clipped - 8 lines]
> > 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
Patricia Shanahan - 09 Aug 2007 20:21 GMT
>>>An insurance company insider told me that they once spotted a penny
>>>difference
[quoted text clipped - 15 lines]
>
> Michael

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

Patricia
John W. Kennedy - 21 Aug 2007 04:57 GMT
> 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.
Signature

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)

Greg R. Broderick - 08 Aug 2007 17:08 GMT
Sirius <katics1@yahoo.com> wrote in news:1186553020.976502.149460
@j4g2000prf.googlegroups.com:

> ok i decided to do a loan amortization program that will take, as
> input, loan amount, loan length (in years) and annual interest rate.
[quoted text clipped - 3 lines]
> 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

Signature

---------------------------------------------------------------------
Greg R. Broderick                  usenet200707@blackholio.dyndns.org

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

Patricia Shanahan - 08 Aug 2007 17:19 GMT
> ok i decided to do a loan amortization program that will take, as
> input, loan amount, loan length (in years) and annual interest rate.
[quoted text clipped - 3 lines]
> 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
Sirius - 08 Aug 2007 17:36 GMT
> > ok i decided to do a loan amortization program that will take, as
> > input, loan amount, loan length (in years) and annual interest rate.
[quoted text clipped - 16 lines]
>
> Patricia

thanks everyone for your input i will take everything into
consideration
Sirius - 08 Aug 2007 18:27 GMT
> > > ok i decided to do a loan amortization program that will take, as
> > > input, loan amount, loan length (in years) and annual interest rate.
[quoted text clipped - 19 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.