sin() in Java

sin(): This method is available in the Math class of Java.

Syntax:

double java.lang.Math.sin(double a)

This method takes one argument of type double as its parameter. This method returns the trigonometric sine of an angle. 

Special cases:

1. If the argument is NaN or an infinity, then the result is NaN.

2. If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters: One parameter is required for this method.

a: an angle, in radians.

Returns: the sine of the argument.

For Example:

Math.sin(0.5) = > It returns 0.479425538604203

Approach

Java

public class Sin {
    public static void main(String[] args) {

        double a = 0.5;
        System.out.println(Math.sin(a));

    }
}

Output:

0.479425538604203

No comments:

Post a Comment