Soooo, I’m taking a Javascript class, which is my fourth programming class. I don’t know if I’m overlooking something small… but my code simply isn’t working. I believe I have it set to work right once I get it there, but the problem is the different rates have to show up in seperate tables. All is good EXCEPT for the different tables part. Now, I’m pretty decent at coding, but I haven’t worked at all with tables yet and for some reason can’t find what I’m doing wrong. We were urged to check the Internet for resources with help on our homework, but to be honest… I’m not even sure how to Google this issue :p
Here’s my code, and [U]thanks
<?xml version = “1.0” encoding = “utf-8”?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“
<html xmlns = “
<head>
<title>Calculating Compound Interest</title>
<style type = “text/css”>
table { width: 30% }
th { text-align: left }
</style>
<script type = “text/javascript”>
<!–
var amount; // current amount of money
var principal = 1000.0; // principal amount
var rate; // interest rate
var counter; // keps track of each rate cycle
for ( counter = 5; counter <= 9; counter++ );
{
document.write(
“<table border = “1”>” ); // begin the table
document.write(
“<caption>Calculating Compound Interest</caption>” );
document.write(
“<thead><tr><th>Year</th>” ); // year column heading
document.write(
“<th>Amount on deposit</th>” ); // amount column heading
document.write( “</tr></thead><tbody>” );
// output a table row for each year
for ( var year = 1; year <= 10; ++year )
{
rate = counter * .01;
amount = principal * Math.pow( 1.0 + rate, year );
document.writeln( “<tr><td>” + year +
“</td><td>” + amount.toFixed(2) +
“</td></tr>” );
} //end for
document.write( “</tbody></table><br />” );
}
// –>
</script>
</head><body></body>
</html>