15,996,429 members

See more:

Hello

I have a**c# asp.net** that computes the **monthly repayment** in a** compound interest** computation .

However a stored procedure which does the same produces a different results.

The codes are as follows:

The Annual interest Rate is

The Term of the Loan is

The Principal outstanding is

-- Attached c# component

Can you peruse the codes and offer some solution or an alternative.

Thanks

Edit (MTH): cleanup the markup

I have a

However a stored procedure which does the same produces a different results.

The codes are as follows:

The Annual interest Rate is

`@BRATES`

The Term of the Loan is

`@MTERM`

The Principal outstanding is

`@AOUTST`

SQL

SET @MMCOMPCNT = @ACOMPCOUNT SET @CCCMTH = @CMONTH SET @CCCYR = @CYEAR --COMPUTING THE DEDUCTION BEGIN --COMPUTING THE DEDUCTION BEGIN SET @MMRATE = @BRATES/(100*12) SET @ZRATE = 1+@MMRATE SET @MTERM = @MMCOMPCNT SET @MMTEMP = POWER(@ZRATE,@MTERM) SET @MMDEDUCT = (@AOUTST*@MMRATE)/(1-(1/@MMTEMP)) --COMPUTING THE DEDUCTION END --COMPUTING THE DEDUCTION END

-- Attached c# component

C#

case "MONTHLY REPAYMENT": double xxprincipal = Convert.ToDouble(txt_Principal.Text); double xxinterest = Convert.ToDouble(txt_Interest.Text); double xxmyear = Convert.ToInt32(txt_Term_Year.Text); double xxmonth = Convert.ToInt32(txt_Term_Month.Text); double mmrate = xxinterest/(12*100); double zrate = 1 +mmrate; double mterm = 12 * xxmyear + xxmonth; double mmtemp = Math.Pow(zrate, mterm); double mrepayment=(xxprincipal*mmrate)/(1-(1/mmtemp)); txt_Monthly.Text = mrepayment.ToString("N");

Can you peruse the codes and offer some solution or an alternative.

Thanks

Edit (MTH): cleanup the markup

Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900

That will allow us to see where they differ.

double xxprincipal = Convert.ToDouble(txt_Principal.Text);

double xxinterest = Convert.ToDouble(txt_Interest.Text);

double xxmyear = Convert.ToInt32(txt_Term_Year.Text);

double xxmonth = Convert.ToInt32(txt_Term_Month.Text);

double mmrate = xxinterest/(12*100);

double zrate = 1 +mmrate;

double mterm = 12 * xxmyear + xxmonth;

double mmtemp = Math.Pow(zrate, mterm);

double mrepayment=(xxprincipal*mmrate)/(1-(1/mmtemp));

txt_Monthly.Text = mrepayment.ToString("N");