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.



write a programme to solve a formula for compound interest using html tags. I want to know how a f..

Answer / 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

More JavaScript Interview Questions

What is the difference between the operators '==' and '==='?

0 Answers  


What are the main features of javascript?

0 Answers  


If 2 methods have same name and same number of parameters, which one will be executed first?

0 Answers  


What does the delete operator do in JavaScript?

1 Answers  


print the following using loop. 54321 4321 321 21 1

2 Answers   Delhi Public School,






How to open a window with no toolbar, but with the location object?

0 Answers  


How do I link an external javascript file to html?

0 Answers  


Can any one tell me about s_objectID used for the anchor tag why it is used, what for and how to use it properly. with an example...please please......

1 Answers  


What is unobtrusive javascript?

0 Answers  


What is event in javascript?

0 Answers  


Define event bubbling?

0 Answers  


Are you concerned that older browsers don't support javascript and thus exclude a set of web users? Individual users?

0 Answers  


Categories