DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

1. Registered User
Join Date
Jul 2014
Posts
13

The area of a square is stored in a double variable named area . Write an expression whose value is length of the diagonal of the square.
Do I use math.sqrt?

2. I am also same problem. Please anyone help me about Java Math. I need to learn about it. Thanks
Last edited by Anglin; 01-03-2015 at 03:14 PM.

3. Registered User
Join Date
Jul 2014
Posts
13
You can read the next article azillionmonkeys[dot]com/qed/sqroot[dot]html

4. Registered User
Join Date
Aug 2014
Posts
1
Originally Posted by Anglin
I am also same problem. Please anyone help me about Java Math. I need to learn about it. Thanks
Because you stated "a square", you will use the Pythagorean theorem. The diagonal of the square if the hypotenuse of a triangle whose two sides are the sides of your square. The Pythagorean theorem states that the square of the hypotenuse of a triangle is equal to the sum of the squares of the other two sides.
Therefore, one version of the calculation would be:

hypotenuse = Math.sqrt(side1 * side1 + side2 *side2);

5. Registered User
Join Date
Jul 2014
Posts
13

#### Posting Permissions

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

 FAQ Latest Articles Java .NET XML Database Enterprise