Link to home
Start Free TrialLog in
Avatar of identityless
identityless

asked on

Schedule Loan output in java

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
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

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
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

Avatar of identityless
identityless

ASKER

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.
>>  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
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?
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
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?

 
>> 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
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
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 + ....);
}

ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)?