This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

I am attempting to find the angle of a triangle based on the length of the sides. I have no knowledge of any angles of the triangle.

I am using the equation: b^2 = a^2 + c^2 - 2ac cos B

where ^ denotes power of

B is the angle I am trying to find

b is the length of the side opposite B

a and c are the lengths of th other two sides.

So, if I have the data; b = 5, c = 4, a = 6

25 = 16 + 36 - 2*4*6 cos B

=> 25 = 52 - 48 cos B

=> 48 cos B = 27

=> cos B = 27/48

=> cos B = 0.5625

Is there a method to find B on its own? i.e. inverse of cos B?

I am using the equation: b^2 = a^2 + c^2 - 2ac cos B

where ^ denotes power of

B is the angle I am trying to find

b is the length of the side opposite B

a and c are the lengths of th other two sides.

So, if I have the data; b = 5, c = 4, a = 6

25 = 16 + 36 - 2*4*6 cos B

=> 25 = 52 - 48 cos B

=> 48 cos B = 27

=> cos B = 27/48

=> cos B = 0.5625

Is there a method to find B on its own? i.e. inverse of cos B?

double angle = 45;

double cos;

cos = Math.cos(angle);

angle = Math.acos(cos);

System.out.println(cos);

System.out.println(angle);

The println on angle at the end does not print out 45

The result is given in radians. You need Math.toDegrees

Exactly.

From the docs:

acos returns the arc cosine of an angle, in the range of 0.0 through pi.

But as the doc says:

The conversion from radians to degrees is generally inexact;

Users should not expect cos(toRadians(90.0)) to exactly equal 0.0.

returns

45.0

So, your code should be:

double angle = 45;

double cos;

cos = Math.cos(Math.toRadians(an

angle = Math.acos(cos);

System.out.println(cos);

System.out.println(Math.to

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.