Javascript interest rate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenin42001
    New Member
    • Jan 2007
    • 29

    #1

    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>moneylin e.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=parse Float(response) ;
    document.writel n(
    "<table border = \"1\" width = \"100%\">" );
    document.writel n(
    "<caption> Invest money with us at 5% interest you earn </caption>" );
    document.writel n(
    "<thead><tr ><th align = \"left\">Yea r</th>" );
    document.writel n(
    "<th align = \"left\">Amo unt on deposit</th>" );
    document.writel n( "</tr></thead>" );

    for ( var year = 1; year <= 10; ++year ) {
    amount = principal * Math.pow( 1.0 + rate, year );
    document.writel n( "<tbody><tr><td >" + year +
    "</td><td>" + Math.round( amount * 100 ) / 100 +
    "</td></tr>" );
    }
    document.writel n( "</tbody></table>" );
    // -->
    </script>
    </body>
    </html>[/HTML]
    Last edited by gits; Oct 7 '07, 04:16 PM. Reason: added code tags
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by lenin42001
    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>moneylin e.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=parse Float(response) ;
    document.writel n(
    "<table border = \"1\" width = \"100%\">" );
    document.writel n(
    "<caption> Invest money with us at 5% interest you earn </caption>" );
    document.writel n(
    "<thead><tr ><th align = \"left\">Yea r</th>" );
    document.writel n(
    "<th align = \"left\">Amo unt on deposit</th>" );
    document.writel n( "</tr></thead>" );

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

    Debasis Jana

    Comment

    Working...