SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Project, can't find problem.

    I have this basic little porject for class and I can't seem to find what's wrong in it. It looks good to go in my eyes, but when I go to check it nothing appears.....have a look. It's due tomorrow morning...



    <script type="text/javascript">
    /* Start code and set up some variables
    */
    var name = prompt("Enter your name:");
    alert(name + ", You need to do a few more calculations.");
    var one = prompt("enter First Number:",0);
    var two = prompt("enter Second Number:",0);

    /* Parse the numbers given
    */
    var numone = parseFloat(one);
    var numtwo - parseFloat(two);

    /* Do Calculations
    */
    var add = numone + numtwo;
    var subtract = numone - numtwo;
    var multiply = numone * numtwo;
    var divide = numone / numtwo;
    var squareone = numone * numtwo;
    var squaretwo = numone * numtwo;
    var sumsquare = squareone + squaretwo;

    /* Print results
    */
    document.write("<center><h1><u>Assignment 1 - Sample Solution</u></h1></center>");
    document.write("\xA0The first number you entered was: " + numone + "<br>");
    document.write("\xA0The second number you entered was: " + numtwo + "<br><br>");

    document.write("\xA0Here are the calculations I performed with thembr><br>");

    document.write("Addition: " + numone + " + " + numtwo + " = " + add + "<br>");
    document.write("Subtraction: " + numone + " - " + numtwo + " = " + subtract + "<br>");
    document.write("Multiply: " + numone + " x " + numtwo + " = " + multiply + "<br>");
    document.write("Divide: " + numone + " / " + numtwo + " = " + divide + "<br>");

    document.write("<h3>Squared</h3>");
    document.write("Square One: " + numone + "<sup>2</sup> = " + squareOne + "<br>");
    document.write("Square Two: " + numtwo + "<sup>2</sup> = " + squareTwo + "<br>");
    document.write("Sum of Squares: " + numone + "<sup>2</sup>" + numtwo + "<sup>2</sup> = " + sumSquare);

    </script>


    Any help is appreciated, I'm kinda new to javascript.

  2. #2
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    var numtwo = parseFloat(two);


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
  •