Calculate Hyperbolic cosine in Java
Description
The following code shows how to calculate Hyperbolic cosine.
Example
/* w w w .jav a 2s .c om*/
public class Main {
public static void main(String[] args) {
// Obtain angle in degrees from user
double degs = 20d;
// Convert degrees to radian
double rads = Math.toRadians(degs);
// Calculate Hyperbolic cosine
double cosHA = (Math.exp(rads) + Math.exp(-rads)) / 2;
System.out.println("Hyperbolic cosine = " + cosHA);
}
}
The code above generates the following result.