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


  • import java.util.*; : This line imports the java.util package which contains the Scanner class that we use later to take user input.
  • public class Hyperbolic_Cosine: This line declares a public class called Hyperbolic_Cosine.
  • public static void main(String[] args): This line is the main method that gets executed when the program runs. It takes an array of strings args as input.
  • Scanner input = new Scanner(System.in);: This line creates a new instance of the Scanner class which we use to take user input from the command line.
  • double deg = 0;: This line declares a double variable called deg and initializes it to 0.
  • System.out.print("Enter The Degree : ");: This line prints out the message "Enter The Degree : " to the console.
  • deg = input.nextDouble();: This line takes a double input from the user using the Scanner class and assigns it to the deg variable.
  • double rad = Math.toRadians(deg);: This line converts the deg value from degrees to radians using the Math.toRadians() method and assigns it to the rad variable.
  • System.out.print("Hyperbolic Cosine : " + Math.cosh(rad)); : This line prints out the message "Hyperbolic Cosine : " to the console along with the result of the Math.cosh() method called on the rad value. The Math.cosh() method returns the hyperbolic cosine of the given value.

Source Code

import java.util.*;
public class Hyperbolic_Cosine
{
	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 Cosine : " + Math.cosh(rad));
	}
}

Output

Enter The Degree : 583.12
Hyperbolic Cosine : 13150.522295616724

Example Programs