/    Sign up×
Community /Pin to ProfileBookmark

Needing help – feeling stupid

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[/U] to anyone who can tell me why it only shows me the last table, instead of all of them seperately.

<?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 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>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Logic_AliJul 31.2008 — 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. [/quote]There's noting wrong with the HTML being generated, otherwise you would see all your data one way or another.

With that in mind I suggest you ask yourself how the problem could arise.

You really do need to get this yourself.
Copy linkTweet thisAlerts:
@babylikesburghauthorAug 01.2008 — Actually, everything was right, there was just a poorly placed semicolon.
Copy linkTweet thisAlerts:
@JMRKERAug 01.2008 — I'm going to assume you found the problem here:
[code=php]
for ( counter = 5; counter <= 9; counter++ );
[/code]
×

Success!

Help @babylikesburgh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...