Java sin() method
sin() method is used to return the sine value of the specified double type parameter.
grammar
double sin(double d)
parameter
d -- Any native data type.
return value
Returns the sine value of the specified double type parameter.
Example
public class Test{ public static void main(String args[]){ double degrees = 45.0; double radians = Math.toRadians(degrees); System.out.format("pi 的值为 %.4f%n", Math.PI); System.out.format("%.1f 度的正弦值为 %.4f%n", degrees, Math.sin(radians)); } }
Compile the above program and the output result is:
pi 的值为 3.1416 45.0 度的正弦值为 0.7071