Ask 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 of the Math class to calculate the length of the third side. Save the result in a new double variable named c.

+3
Answers (1)
  1. 2 February, 06:37
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers