J
Jason
Hi there. I am needing a little assistance with something I am working
on.
I have two methods as part of a loan calculator I am building and I
cannot get two calculations working correctly.
assume that I have all variables methods etc in place.
The first code is supposed to calculate the monthly repayment amount
required to pay off a loan at a fixed rate over a fixed term. The
coding I have is:
repayment = principle * interestRate * (Math.pow ((1 + interestRate),
timePeriod)) / (Math.pow ((1 + interestRate), timePeriod) - 1);
I seen to get unusually high figures (ie 6 figure monthly repayments
for a loan of 50000 on a rate of 5%pa over 25 years. Can anyone see
where it is going wrong?
And the second one:
this peice of chode is meant to determine the total amount repaid if a
set repayment is being made at a fixed interest rate. it should also
tell you the number of years and months it takes to pay it off.
while (principle > 0.0){
months = months + 1;
principle = principle * (1 + ((interestRate / 12.0) / 100)) -
repayment;
totalRepayment = totalRepayment + repayment;
}
totalRepayment = totalRepayment + principle;
writer.println("Total repayment amount: $" + totalRepayment);
years = months / 12;
monthRemainder = months % 12;
writer.println("Over " + years + " years and " + monthRemainder + "
months.");
When testing this component i get very strange results. I can get
different results every time using the exact same data.
Can anyone help me?
Thanks
on.
I have two methods as part of a loan calculator I am building and I
cannot get two calculations working correctly.
assume that I have all variables methods etc in place.
The first code is supposed to calculate the monthly repayment amount
required to pay off a loan at a fixed rate over a fixed term. The
coding I have is:
repayment = principle * interestRate * (Math.pow ((1 + interestRate),
timePeriod)) / (Math.pow ((1 + interestRate), timePeriod) - 1);
I seen to get unusually high figures (ie 6 figure monthly repayments
for a loan of 50000 on a rate of 5%pa over 25 years. Can anyone see
where it is going wrong?
And the second one:
this peice of chode is meant to determine the total amount repaid if a
set repayment is being made at a fixed interest rate. it should also
tell you the number of years and months it takes to pay it off.
while (principle > 0.0){
months = months + 1;
principle = principle * (1 + ((interestRate / 12.0) / 100)) -
repayment;
totalRepayment = totalRepayment + repayment;
}
totalRepayment = totalRepayment + principle;
writer.println("Total repayment amount: $" + totalRepayment);
years = months / 12;
monthRemainder = months % 12;
writer.println("Over " + years + " years and " + monthRemainder + "
months.");
When testing this component i get very strange results. I can get
different results every time using the exact same data.
Can anyone help me?
Thanks