• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

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
0
identityless
Asked:
identityless
  • 6
  • 5
1 Solution
 
TimYatesCommented:
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
 
suprapto45Commented:
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
 
identitylessAuthor Commented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
TimYatesCommented:
>>  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
 
identitylessAuthor Commented:
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
 
TimYatesCommented:
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
 
identitylessAuthor Commented:
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
 
TimYatesCommented:
>> 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
 
TimYatesCommented:
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
 
identitylessAuthor Commented:
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
 
TimYatesCommented:
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
 
identitylessAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now