Hope this is the right place for the post.
I'm programming a program to help my at my work.
this 1 part I just can't get right.
Here is the code. I used the 'degrees * Math.PI / 180' in place 'Math.toRadians (degrees)'
that doesn't make a difference.
public class Polar { public static void main (String [] args) { double degrees45 = 45.0; double radians45 = Math.toRadians (degrees45); System.out.println ("The sine of " + degrees45 + "degrees is " + (Math.sin (radians45))); System.out.println ("The cosine of " + degrees45 + "degrees is " + (Math.cos (radians45))); double degrees90 = 90.0; double radians90 = Math.toRadians (degrees90); System.out.println ("\nThe sine of " + degrees90 + "degrees is " + (Math.sin (radians90))); System.out.println ("The cosine of " + degrees90 + "degrees is " + (Math.cos (radians90))); double degrees135 = 135.0; double radians135 = Math.toRadians (degrees135); System.out.println ("\nThe sine of " + degrees135 + "degrees is " + (Math.sin (radians135))); System.out.println ("The cosine of " + degrees135 + "degrees is " + (Math.cos (radians135))); double degrees180 = 180.0; double radians180 = Math.toRadians (degrees180); System.out.println ("\nThe sine of " + degrees180 + "degrees is " + (Math.sin (radians180))); System.out.println ("The cosine of " + degrees180 + "degrees is " + (Math.cos (radians180))); double degrees270 = 270.0; double radians270 = Math.toRadians (degrees270); System.out.println ("\nThe sine of " + degrees270 + "degrees is " + (Math.sin (radians270))); System.out.println ("The cosine of " + degrees270 + "degrees is " + (Math.cos (radians270))); } }
The display
The sine of 45.0degrees is 0.7071067811865475
The cosine of 45.0degrees is 0.7071067811865476
The sine of 90.0degrees is 1.0
The cosine of 90.0degrees is 6.123031769111886E-17
The sine of 135.0degrees is 0.7071067811865476
The cosine of 135.0degrees is -0.7071067811865475
The sine of 180.0degrees is 1.2246063538223773E-16
The cosine of 180.0degrees is -1.0
The sine of 270.0degrees is -1.0
The cosine of 270.0degrees is -1.836909530733566E-16
If you look at the cosine of 90 degrees, why does it give me 6.123031769111886E-17 and not 0.
Same as sine of 180 and cosine of 270.
The sine and cosine of 45 and 135 works fine.
Is it something I'm missing or what.
Please help me.