Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Thanked 0 Times in 0 Posts

    Angry Creating a Pythagorean Theorem Calculator (Simple!)

    Hey guys. This should be extremely easy for you to answer. This is actually for an intro to computers class I am taking and I am completely stumped. Basically I have to create a really simple Pythagorean Theorem calculator and this is what I have so far:

    <title>A Pythagoras Conversion</title>

    <script type="text/javascript">

    var right_leg, left_leg, hypotenuse;

    alert ("This calculates the hypotenuse of a right-angled triangle using the Pytahgorean Thereom. Press <OK> to continue!");

    right_leg=prompt("Enter the length of the right leg.");

    left_leg=prompt("Enter the length of the left leg.");

    sq1 = right_leg*right_leg;
    sq2 = left_leg*left_leg;

    hypotenuse = math.sqrt(sq1 + sq2);

    alert ("The Hypotenuse= ");



    Everything works except for when it comes to it actually calculating. The calculation window never pops up. Please tell me what I am doing wrong in the calculation here....it is driving me nuts. :/

    Thanks so much...

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,700 Times in 2,676 Posts
    hypotenuse = Math.sqrt(sq1 + sq2);
    alert ("The Hypotenuse= " + hypotenuse);

    "Life is like a mirror, we get the best results when we smile at it. " - Anonymous


Posting Permissions

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