HypFun.java Source code

Java tutorial

Introduction

Here is the source code for HypFun.java

Source

strictfp class HypFun {
    public static void main(String[] args) {
        double rads, degs, sinHA, cosHA, tanHA, asinHA;

        // Obtain angle in degrees from user
        degs = 20d;
        // Convert degrees to radian
        rads = Math.toRadians(degs);

        // Calculate hyperbolic sine
        sinHA = (Math.exp(rads) - Math.exp(-rads)) / 2;
        System.out.println("Hyperbolic sine = " + sinHA);

        // Calculate Hyperbolic cosine
        cosHA = (Math.exp(rads) + Math.exp(-rads)) / 2;
        System.out.println("Hyperbolic cosine = " + cosHA);

        // Calculate hyperbolic tangent
        tanHA = sinHA / cosHA;
        System.out.println("Hyperbolic tangent = " + tanHA);

        // Calculate hyperbolic arc-sine
        asinHA = Math.log(sinHA + Math.sqrt((sinHA * sinHA) + 1.0));
        degs = Math.toDegrees(asinHA);
        System.out.println("Arc hyperbolic sine = " + degs);
    }
}