SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    :) Have a nice day! james34's Avatar
    Join Date
    Jun 2000
    Location
    KY, USA
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question interest calculator

    I can not get this to actually add the interest earned to the principle, instead it is displaying the two numbers as is. How do I make it add the two?
    Code:
     <SCRIPT LANGUAGE="JavaScript"><!--
    var dollar;
    dollar=prompt("Please enter dollar amount","");
    var time;
    time=prompt("Please enter time in years","");
    var rate;
    rate=prompt("Please enter annual interest rate","");
    var percent;
    percent=rate/100;
    var prt;
    prt=dollar*percent*time;
    var acc;
    acc=dollar+prt;
    document.write("If you invest $");
    document.write(dollar);
    document.write(" for ");
    document.write(time);
    document.write(" years at ");
    document.write(rate);
    document.write("% your interest would be $");
    document.write(prt);
    document.write(" and your total interest and principle would be $");
    document.write(acc);
    //--></SCRIPT>
    Last edited by james34; Jun 29, 2003 at 21:18.
    james34
    My Site

  2. #2
    :) Have a nice day! james34's Avatar
    Join Date
    Jun 2000
    Location
    KY, USA
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks anyway, I got it.
    Code:
     <SCRIPT LANGUAGE="JavaScript"><!--
    var dollar;
    dollar=prompt("Please enter dollar amount","");
    dollar=parseFloat(dollar);
    var time;
    time=prompt("Please enter time in years","");
    var rate;
    rate=prompt("Please enter annual interest rate","");
    var percent;
    percent=rate/100;
    var prt;
    prt=dollar*percent*time;
    prt=parseFloat(prt);
    var acc;
    acc=(dollar+prt);
    document.write("If you invest $");
    document.write(dollar);
    document.write(" for ");
    document.write(time);
    document.write(" years at ");
    document.write(rate);
    document.write("% your interest would be $");
    document.write(prt);
    document.write(" and your total interest and principl would be $ ");
    document.write(acc);
    //--></SCRIPT>
    
    james34
    My Site


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •