I tried the code .The answer should be 0.66913060635885821382627333068678
by calculator.
But I use netbean to run Java code to calculate eh
-0.9165215479156338
time = Math.sin(42.0);
System.out.println(time);
Why?
I tried the code .The answer should be 0.66913060635885821382627333068678
by calculator.
But I use netbean to run Java code to calculate eh
-0.9165215479156338
time = Math.sin(42.0);
System.out.println(time);
Why?
Because you're calculating the sine of 42 radians
.
Try converting to radians first:
time = Math.sin(Math.toRadians(42.0));
As per the java doc of the method.
Parameters:
- a - an angle, in radians.
Returns:
the sine of the argument.
The values you see is for sin of 42 radians not for sin of 42 degrees