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 / 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 |
What is dataview in javascript?
How do you trim in javascript?
Should I learn java first or javascript?
What is whitespace in javascript?
Should you disable javascript?
How do I add a javascript event handler to an html page element?
What are the main uses of javascript?
hi iM rahul.my questions is my project is a web based & developed using java,jsp. when i record it using qtp what script i will get like either browser("jdfjkf").page("nkf").... or javawindow("f d ").javaedit("Dasf").... plz clarify my doubt asap and i also need some vbscipt of java coding?
How to set the cursor to wait?
how to run java script program
When would you use javascript closures?
What is data type in javascript?