Returns the trigonometric tangent of an angle. Special cases:
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

package com.logicbig.example.math;
public class TanExample {
public static void main(String... args) {
findTangent(0);
findTangent(30);
findTangent(45);
findTangent(60);
findTangent(120);
}
private static void findTangent(double degrees) {
double radians = Math.toRadians(degrees);
double tanValue = Math.tan(radians);
System.out.printf("Tangent of %s degree = %.2f %n", degrees, tanValue);
}
}
Output
Tangent of 0.0 degree = 0.00
Tangent of 30.0 degree = 0.58
Tangent of 45.0 degree = 1.00
Tangent of 60.0 degree = 1.73
Tangent of 120.0 degree = -1.73