37.2k views
5 votes
Here is the definition of the Pythagoras function:

static double Pythagoras (double x, double y) {
// Computes the length of the hypotenuse of a right
// triangle, where the sides of the triangle are x and y.
return Math.sqrt( x*x + y*y );
}

Now, what is the result of the following statement:
totalLength = 17 + Pythagoras (12,5);

Select one:
a. 10
b. 60
c. 30
d. 35

User Aesthete
by
7.9k points

1 Answer

4 votes

Final answer:

The result of the statement totalLength = 17 + Pythagoras (12,5) is 30.

Step-by-step explanation:

The statement totalLength = 17 + Pythagoras(12,5) computes the length of the hypotenuse of a right triangle with sides of length 12 and 5. The Pythagoras function calculates this length using the Pythagorean theorem, which states that in a right triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides. Using the Pythagoras function, the length of the hypotenuse is computed as:

totalLength = 17 + Math.sqrt(12*12 + 5*5)

totalLength = 17 + Math.sqrt(144 + 25)

totalLength = 17 + Math.sqrt(169)

totalLength = 17 + 13

totalLength = 30

User Mapping Dom
by
9.0k points