Write a Java program to Find the hyperbolic tangent of an angle


The program starts by importing the java.util package, which contains the Scanner class that allows user input. Then, a double variable deg is initialized to 0 to store the degree value entered by the user.

The user is prompted to enter the degree value using the System.out.print() method and the Scanner class. The input value is then stored in the deg variable using the input.nextDouble() method.

Next, the toRadians() method of the Math class is used to convert the degree value to radians, which is required for the tanh() method. The result of tanh() is then printed to the console using the System.out.print() method.

Source Code

import java.util.*;
public class Hyperbolic_Tangent
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		double deg = 0;
 
		System.out.print("Enter The Degree : ");
		deg = input.nextDouble();
 
		double rad = Math.toRadians(deg);
		System.out.print("Hyperbolic Tangent : " + Math.tanh(rad));
	}
}

Output

Enter The Degree : 1863
Hyperbolic Tangent : 1.0

Example Programs