Ask Question
27 March, 05:32

Given double variables a and b that contain the lengths of the two short sides of a right triangle, write a statement that uses the methods of the Math class to calculate the length of the third side. Save the result in a new double variable named c.

+5
Answers (1)
  1. 27 March, 07:39
    0
    double c = Math. sqrt ((Math. pow (a, 2)) + Math. pow (b, 2));

    Explanation:

    given that a and b = two short sides of the right-angles triangle

    c = hypothenus

    Since the pythogoras theorem says the length of the hypothenus is equal to the square root of the sum of squares of the two other sides

    A complete java code using methods from the Java Maths Class (Power and Square root) is given below

    public class StringLength {

    public static void main (String[] args) {

    double a = 5;

    double b = 7;

    double c = Math. sqrt ((Math. pow (a, 2)) + Math. pow (b, 2));

    System. out. println ("The Length of the Third Side (The Hypothenus) is " + c);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Given double variables a and b that contain the lengths of the two short sides of a right triangle, write a statement that uses the methods ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers