?
Solved

Schedule Loan output in java

Posted on 2005-04-22
12
Medium Priority
?
246 Views
Last Modified: 2010-03-31
Suppose I have three parameters - Original Principal = 500, terms(in months) = 12, and Interest rate = 8.25. I want write a function that produce the following below. For that monthly payment, I can code it.
For example. P = 500, i = (8.25/100)/12, and n = 12 (months).
monthlypayment = P [(i(1 + i)^n  / ((1 + i)^n) - 1]
43.55 = monthlypayment.

But what about Cumulative principal and  cumulative interest rate? (Note: those aren't negative numbers, just - in front).

Month      Total      Principal      Interest      Cum Princ      Cum Int
1      -$43.55      -$40.11      -$3.44      -$40.11      -$3.44
2      -$43.55      -$40.39      -$3.16      -$80.50      -$6.60
3      -$43.55      -$40.67      -$2.88      -$121.17      -$9.48
4      -$43.55      -$40.95      -$2.60      -$162.12      -$12.09
5      -$43.55      -$41.23      -$2.32      -$203.35      -$14.41
6      -$43.55      -$41.51      -$2.04      -$244.86      -$16.45
7      -$43.55      -$41.80      -$1.75      -$286.66      -$18.20
8      -$43.55      -$42.09      -$1.47      -$328.75      -$19.67
9      -$43.55      -$42.37      -$1.18      -$371.12      -$20.85
10      -$43.55      -$42.67      -$0.89      -$413.79      -$21.73
11      -$43.55      -$42.96      -$0.59      -$456.75      -$22.33
12      -$43.55      -$43.25      -$0.30      -$500.00      -$22.62
0
Comment
Question by:identityless
  • 6
  • 5
12 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 13840873
Is this a homework assignment?

We can't write the code for you I'm afraid.  How far have you got?

If you post your code, we may be able to suggest changes...

Tim
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13840993
Hi,

TimYates is correct, we cannot write homework for you.

However, what do you mean by Cumulative principal and  cumulative interest rate? Have you implemented it? I saw from your output that you have successfully implemented it. Can you elaborate more?

Regards
Dave

0
 

Author Comment

by:identityless
ID: 13843212
I don't really need the full code. I'm just testing the output from a program to that of Excel. The Interest Rate is 8.25 but I don't see where the 3.44 comes from? A little help would be appreciated.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 13843263
>>  The Interest Rate is 8.25 but I don't see where the 3.44 comes from?

Nor do I...

Shouldn't it be:

        $3.31

even if it was using the wrong column (and was doing the interest on the "Total" figure), it should be

        $3.59

Are you sure it's 8.25?

Tim
0
 

Author Comment

by:identityless
ID: 13843433
In Excel, you can try Mortage Amortization.

Loan principal amount: 500
Annual Interest Rate: 8.25
Loan period in years: 1 (for 12 months)

I got 3.44 I know it uses the PMT formulas in Excel, but what's the pseduo so I can implement it in Java?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13843488
Right...I think I see what's going on...

You have an annual interest of 8.25%

That's a monthly interest of

    0.6875%

Multiply that by your amount of $500, and you get the first months interest (of $3.44 -- to 2dp)

Tim
0
 

Author Comment

by:identityless
ID: 13843824
Thanks you're getting closer for the points.

I got $343.75, am I suppose to divide by 100? If so, is that always the case?

Can you tell me how this output below was produce for remaining principal?
$500.00
$459.89
$419.50
$378.83
$337.88
$296.65
$255.14
$213.34
$171.26
$128.89
$86.23
$43.27

Interest:
$3.44
$3.16
$2.88
$2.60
$2.32
$2.04
$1.75
$1.47
$1.18
$0.89
$0.59
$0.30

Cumulative Interest:
$3.44
$6.60
$9.48
$12.08
$14.40
$16.44
$18.19
$19.66
$20.84
$21.73
$22.32
$22.62

How do I get from $3.44 to $6.60? I know it's 3.44 + $3.16, but where did that 3.16 comes from?

 
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13843840
>> I got $343.75, am I suppose to divide by 100? If so, is that always the case?

Yeah, you want to multiply by  0.6875 PER CENT!  So divide 500 by 100, then multiply by 0.6875

Or of course, just multiply values by 0.006875 (which is easier) ;-)

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13843876
They borrowed $500

And, they are paying off $43.55 per month...

But!  In the first month, they get interest of $3.44

So, we have (after month 1)

  500 - 43.55 + 3.44 == 459.89

And the interest for that (which will be added for month 2) is:

  459.89 * 0.006875 == (wait for it)  $3.16 (to 2dp)

Isn't maths wonderful?

Hope this helps!

Tim
0
 

Author Comment

by:identityless
ID: 13843988
Thanks, if you can answer this one, you'll definately get the points!

So, then this becomes 459.89 (remaining principal) - 43.55(fixed-number) + 3.16(remaining interest rate) = 419.5
419.5 * .006875 (fixed interest rate) = 2.88

Now, how would I code it to show the months? For instance, would it be something like:

n = number of terms (in months)
for (int i = 1; i <= n; i++)
{
remainingPrincipal = ....
rInteresRate = ....
System.out.print( i + ....);
}

or
i = 1;
while(remaingPrincipal >= 0)
{
remainingPrincipal = ....
rInteresRate = ....
System.out.print(i + ....);
}

0
 
LVL 35

Accepted Solution

by:
TimYates earned 375 total points
ID: 13844018
the first one I reckon...

So you know the starting value for "remainingPrincipal", you know the rate of interest per year so you can calculate the rate of interest per month

As I said originally, I can fix code for you, but I cannot write the code :-(

Calculating the $43.55 is probably the trickiest bit...  I'd have to have a think about how to do that...
0
 

Author Comment

by:identityless
ID: 13844068
I already coded that part.
****
For example. P = 500, i = (8.25/100)/12, and n = 12 (months).
monthlypayment = P [(i(1 + i)^n  / ((1 + i)^n) - 1]
43.55 = monthlypayment.
****

You recommened the 1st one. So even if n = 24, 36, 72, etc, eventually, the remaining principal will be the minimum, when n goes from 1 to (last term)?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month17 days, 12 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question