babylikesburgh
07-31-2008, 06:25 PM
Yes, this is part of a homework problem. I've got it all except one error (obviously), so I'm certianly not asking for anyone to do this for me. However, in order for me to learn how to do this, I need to figure out how to get it right. Now, I need a new table to appear for each rate. When the code runs, it only shows the final table, not the others. I can about swear I have everything in the right place, but yeah... it's a no go. All I need is a suggestion or hint as to why my tables aren't all printing out. Thanks a bunch!
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<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 apr
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>
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<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 apr
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>