469,314 Members | 2,182 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,314 developers. It's quick & easy.

Javascript interest rate

Please can you help Have tried various means but cannot get this to work. The saver is prompted for the amount they wish to invest & a time period(in years) If initial investment is over £1000 & if investment period is more tham 12 years the interest rate is 7% otherwise use 6%. Have tried if else statement & two "for" statements but neither work..........<!-- Using the for loop -->

[HTML]<html>
<head>
<title>moneyline.co.uk</title>
</head>
<body bgcolor="white">
<script type = "text/javascript">
<!--
var amount=0.0, principal = 0.0, rate = .05,response;
response = window.prompt( "How much money would you like to invest ?", "0" );
principal=parseFloat(response);
document.writeln(
"<table border = \"1\" width = \"100%\">" );
document.writeln(
"<caption> Invest money with us at 5% interest you earn </caption>" );
document.writeln(
"<thead><tr><th align = \"left\">Year</th>" );
document.writeln(
"<th align = \"left\">Amount on deposit</th>" );
document.writeln( "</tr></thead>" );

for ( var year = 1; year <= 10; ++year ) {
amount = principal * Math.pow( 1.0 + rate, year );
document.writeln( "<tbody><tr><td>" + year +
"</td><td>" + Math.round( amount * 100 ) / 100 +
"</td></tr>" );
}
document.writeln( "</tbody></table>" );
// -->
</script>
</body>
</html>[/HTML]
Oct 7 '07 #1
1 1864
dmjpro
2,476 2GB
Please can you help Have tried various means but cannot get this to work. The saver is prompted for the amount they wish to invest & a time period(in years) If initial investment is over £1000 & if investment period is more tham 12 years the interest rate is 7% otherwise use 6%. Have tried if else statement & two "for" statements but neither work..........<!-- Using the for loop -->

[HTML]<html>
<head>
<title>moneyline.co.uk</title>
</head>
<body bgcolor="white">
<script type = "text/javascript">
<!--
var amount=0.0, principal = 0.0, rate = .05,response;
response = window.prompt( "How much money would you like to invest ?", "0" );
principal=parseFloat(response);
document.writeln(
"<table border = \"1\" width = \"100%\">" );
document.writeln(
"<caption> Invest money with us at 5% interest you earn </caption>" );
document.writeln(
"<thead><tr><th align = \"left\">Year</th>" );
document.writeln(
"<th align = \"left\">Amount on deposit</th>" );
document.writeln( "</tr></thead>" );

for ( var year = 1; year <= 10; ++year ) {
amount = principal * Math.pow( 1.0 + rate, year );
document.writeln( "<tbody><tr><td>" + year +
"</td><td>" + Math.round( amount * 100 ) / 100 +
"</td></tr>" );
}
document.writeln( "</tbody></table>" );
// -->
</script>
</body>
</html>[/HTML]
Sorry .....................
What are the inputs and what will be the outputs ?

Debasis Jana
Oct 8 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Bob Phillips | last post: by
1 post views Thread by Drakscon | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.