How do I go about converting the Pythagorean Theorem into Java?

is it a little like this? I'm just lost on how to get put square root into that formula. What is the proper way to do it?

z = (x * x) + (y * y)

Printable View

- 03-09-2010, 07:05 PMfsuarjun03converting an algebraic equation to Java
How do I go about converting the Pythagorean Theorem into Java?

is it a little like this? I'm just lost on how to get put square root into that formula. What is the proper way to do it?

z = (x * x) + (y * y) - 03-09-2010, 07:42 PMStormyWaters
Check out this class

Math (Java 2 Platform SE v1.4.2) - 03-09-2010, 07:58 PMfsuarjun03
Ahhh. That helps a bit but how do I put it all together.

I am trying to create a class to solve for all parts of Pythagoreans Theorem. I am starting with solving for the sides and then moving on to solving for the angles. I'm just going to show you what I have so far. I know its not right but here.

Code:`public class Pythagoras`

{

private int x, y, z;

public Pythagoras(int x, int y, int z)

{

x = (int) 1;

y = (int) 1;

z = (int) 1;

}

public void calculate()

{

z = ((x * x) + (y * y));

x = ((z * z) - (y * y));

y = ((z * z) - (x * x));

}

public int getSideX()

{

return x;

}

public int getSideY()

{

return y;

}

public int getSideZ()

{

return z;

}

}

Code:`public static double sqrt(double a)`