Advertisement
RokiAdhytama

Interest - Chapter 9

Jul 2nd, 2022
916
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.00 KB | None
  1.  
  2. <html xmlns = "http://www.w3.org/1999/xhtml">
  3.    <head>
  4.       <title>Calculating Compound Interest</title>
  5.  
  6.       <script type = "text/javascript">
  7.          <!--
  8.          var amount, principal = 1000.0, rate = .05;
  9.  
  10.          document.writeln(
  11.             "<table border = \"1\" width = \"100%\">" );
  12.          document.writeln(
  13.             "<caption>Calculating Compound Interest</caption>" );
  14.          document.writeln(
  15.             "<thead><tr><th align = \"left\">Year</th>" );
  16.          document.writeln(
  17.             "<th align = \"left\">Amount on deposit</th>" );
  18.          document.writeln( "</tr></thead>" );
  19.  
  20.          for ( var year = 1; year <= 10; ++year ) {
  21.             amount = principal * Math.pow( 1.0 + rate, year );
  22.             document.writeln( "<tbody><tr><td>" + year +
  23.                "</td><td>" + Math.round( amount * 100 ) / 100 +
  24.                "</td></tr>" );
  25.          }
  26.  
  27.          document.writeln( "</tbody></table>" );
  28.          // -->
  29.       </script>
  30.  
  31.    </head
Advertisement
RAW Paste Data Copied
Advertisement