Devendra Dubey

Devendra Dubey

  • NA
  • 73
  • 653

Same formula working in JavaScript but not in C#

Aug 2 2017 5:35 AM
This JavaScrpit function produce Correct Result
 
<script type="text/javascript">
function Function() {
amount = document.getElementById("Amount").value;
months = document.getElementById("Months").value;
intrest = document.getElementById("Intrest").value;
quaters = Math.floor(months / 3);
monthpayment = parseInt(amount) * ((Math.pow(intrest / 400 + 1, quaters) - 1) / (1-(Math.pow(intrest / 400 + 1,(-1/3)))));
document.getElementById("MaturityAmt").value = monthpayment.toFixed(2);
}
</script>
 
But Same logic not working in C#
 
void MyFunction()
{
double amount =Convert .ToDouble ( textBox1.Text) ;
double months =Convert .ToDouble ( textBox2.Text) ;
double intrest =Convert .ToDouble ( textBox3.Text) ;
double quaters = Math.Floor (months / 3);
double maturityamt = int.Parse (textBox1.Text ) * ((Math.Pow (intrest / 400 + 1, quaters) - 1) / (1 - (Math.Pow (intrest / 400 + 1, (-1 / 3)))));
textBox4.Text = maturityamt.ToString ();
}
 
 

Answers (6)