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.

Respuesta :

ijeggs

Answer:

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);

   }

}

ACCESS MORE