Today I'm going to describe you How to make a good loan calculator.That returns you the TotalAmortization Amount and the total Time period in Months as well as in Years Also..

so now the time for having a look on the code and change it according to your need...Code is below:-

///

/// Purpose:This is used for calculating the MortgageLoan...

///

///

///

///

///

protected void btnCalculate_Click(object sender, EventArgs e)

{

#region The Concept And Formula Derivation By Sanjeev

/*For this I have used the Following Formula Which I have Derived After a long calculation

BY USING THIS FORMULA WE CAN CALCULATE THE UNKNOWN TERM...

(1+ R/12)pow T = 12x/(12x-PR)

FOR CALUCULATING THE TOTAL MORTGAGE AMOUNT WE CAN USE THE FOLLOWING FORMULA

A =P(1+r/12)^T

OR U CAN SAY

A =P(1+r/12)^T

WHERE P= Primary Amount ,A=Final Amount ,T= Total Amount

R=Rate(rate/100(convert to points from %age)) ,x = MOnthly Installing Amount

*/

#endregion

double dblAmount, dblTotalAmt, dblInstallment, dblRate, dblTime;

dblAmount = Convert.ToDouble(txtAmount.Text);

dblInstallment = Convert.ToDouble(txtMontlypayment.Text);

dblRate = Convert.ToDouble(txtRate.Text) / 100;

double logBasevalue = 1 + (dblRate / 12);

double logValue = (12 * dblInstallment) / (12 * dblInstallment - (dblAmount * dblRate));

dblTime = Math.Log(logValue, logBasevalue);

double roundMonth = Math.Round(dblTime);

roundMonth = roundMonth < dblTime ? roundMonth + 1 : roundMonth;

double dblYear =roundMonth / 12;

double roundYear = Math.Round(dblYear, 1);

string strYear = Convert.ToString(roundYear);

dblTotalAmt = Math.Round((dblInstallment * dblTime), 2);

lblMonths.Text = roundMonth.ToString();

lblYears.Text = strYear.Substring(0, strYear.LastIndexOf('.') + 2);

lblTotalAmount.Text = dblTotalAmt.ToString();

}

Enjoy Blogging..

Sanjeev Chaudhary

## 1 comment:

Thanks for sharing your code..very useful one.

Post a Comment