I am not a computer programmer but have an assignment that involves javascript. I need a program that will display the interest in a savings account if I deposit $1000 at 5% interest for 10 years. I need it to show the interest each year for each of the 10 years. I can do it with multiplication of 1 through 9 but I can't figure out how to do it with this.
I was given the following info:
a=p(l+r)"n
p is principal
r is annual interest
n is number of years
a is amount on deposit at end of nth year.
Since javascript doesnt recognize exponents I was also given this.
amount = principal * Math.pow(1.0 rate, year);
also use decimals
Math.round(amount * 100)/100
Here is the program that will do multiplication facts for 1 though 9
<HTML>
<head>
<title> Tues Class example 4</title>
<script language="javascript">
function show()
{
var result;
for (var i=1; i<=9; i++)
{
for (var j=1; j<=9; j++)
{
result = j*i;
document.write(i + " x " + j + " = " + result);
}
document.write("<br>");
}
}
</script>
</head>
<body>
<p><input type="button" value="click to see the result" onClick="show()">
</form>
</body>
</HTML>