write a programme to solve a formula for compound interest
using html tags. I want to know how a formula containing
degree (raise to the power) can be solved.

Answer Posted / mangala

<html>
<head>
<script language="JavaScript">
function calculate(formObj)
{
var presentVal = parseFloat(formObj.principalVal.value);
var intRate = parseFloat(formObj.intRate.value)/100.;
var years = parseFloat(formObj.years.value);

var futureVal = presentVal * Math.pow((1.0+intRate),years);
var totalInt = futureVal - presentVal;
futureVal = Math.round(futureVal*100.0)/100.0;
totalInt = Math.round(totalInt*100.0)/100.0;

formObj.futureVal.value = futureVal;
formObj.totalInt.value = totalInt;

return;
}
</script>
</head>

<body>
<h5>Compound Interest Calculator</h5>
<form name="myform">
<pre>
Principal amount : <input type="text"
name="principalVal">
Interest Rate(%) : <input type="text" name="intRate">
Years of Compounding: <input type="text" name="years">
<input type="button" name="calc" value="Calculate"
onclick="calculate(myform)">
</pre>
<hr>
<pre>
Total Interest: <input type="text" name="totalInt">
Future Value: <input type="text" name="futureVal">
<pre>
</form>

</body>
</html>

The raise to the power can be solved using Math.pow method
in javascript.

Is This Answer Correct ?    14 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is this? Var myarray = [[[]]];

586


What is the difference between firstChild and firstElementChild?

581


What is npm javascript?

478


What is decodeuri() function?

499


What is an anonymous function in JavaScript?

537






How to get the last index of a string in javascript?

495


What percentage of websites use javascript?

505


Explain window.onload and ondocumentready?

503


how can i change colour of a image in aspx file?

1535


How to create array in JavaScript?

546


How do I retrieve a cookie with a given name using a regular expression?

498


How do you declare in javascript?

461


How to handle event handlers?

494


Is null in javascript?

475


What are the advantages of javascript?

454