Good Morning,
I'm new to javascript and the professor ask us to do a javascript program of future value calculation program. The details are: Write a program to find future value of monthly investments. Start with an initial investment, make a deposit every 30days, calculate interest on principle compounded daily, display a table showing beginning balance, deposit for the year, interest earned for the year, and ending balance. The table should display the aforementioned information for a duration of your present age to 65. Display result in a table format as shown below.
Future Value Calculation
Initial Investment: $2000
Interest Rate: 12%
Deposit every 30 days: $100
Investment started: 50
Age Beg Bal Interest Deposits Ending Bal
51 2000 324.65 1200 3524.65
52 3524.65 519.01 1200 5243.66
53 5243.66 738.14 1200 7181.79
54 7181.79 985.2 1200 9366.99
55 9366.99 1263.76 1200 11830.74
56 11830.74 1577.82 1300 14708.57
57 14708.57 1944.67 1200 17853.24
58 17853.24 2345.54 1200 21398.77
59 21398.77 2797.5 1200 25396.28
60 25396.28 3307.08 1200 29903.36
61 29903.36 3881.62 1200 34984.98
62 34984.98 4529.4 1300 40814.38
63 40814.38 5272.5 1200 47286.88
64 47286.88 6097.58 1200 54584.46
65 54584.46 7027.83 1200 62812.29
So far, I have done this for the code
<html>
<head>
<title>Future Value Calculation</title>
<style type = "text/css">
table { width: 100% }
th { text-align : left }
</style>
<script type = "text/javascript">
<!--
var EndBal;
var principal = 2000.00;
var rate = .12;
document.writeln(
"<table border = \"1\">" );
document.writeln(
"<thead><tr><th>Future Value Calculation</th>" );
document.writeln(
"<tr><th>Initial Investment:</th>" );
document.writeln(
"<tr><th>Interest Rate:</th>" );
document.writeln(
"<tr><th>Deposit every 30 days:</th>" );
document.writeln(
"<tr><th>Investment started:</th>" );
documnet.writeln(
"<tr><th>Age</th>" );
document.writeln(
"<th>Beg Bal</th>" );
document.writeln(
"<th>Interest</th>" );
document.writeln(
"<th>Deposits</th>" );
document.writeln(
"<th>Ending Bal</th>" );
document.writeln( "</tr></thead><tbody>" );
for ( var age = 28; age <= 65; ++age )
{
EndBal = principal * Math.pow(1.0 + rate, age );
document.writeln( "<tr><td>" + age +
"</td><td>" + EndBal.toFixed(2) +
"</td><tr>" );
}
document.writeln( "</tbody></table>" );
</script>
</head>
<body>
</body>
</html>
Thanks in advance for your help