Answers for "java math secant"

1

cotangent in java

strictfp class TrigFun {
  public static void main(String[] args) {
    double rads, degs, tanA, coTanA;

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

    // Calculate tangent
    tanA = Math.tan(rads);
    System.out.println("Tangent = " + tanA);

    // Calculate cotangent
    coTanA = 1.0 / Math.tan(rads);
    System.out.println("Cotangent = " + coTanA);

    // Calculate arc-tangent
    rads = Math.atan(tanA);
    degs = Math.toDegrees(rads);
    System.out.println("Arc tangent: " + degs);

    // Calculate arc-cotangent
    rads = Math.atan(1 / coTanA);
    degs = Math.toDegrees(rads);
    System.out.println("Arc cotangent: " + degs);
  }
}
Posted by: Guest on November-07-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language