TrigSolv.java Source code

Java tutorial

Introduction

Here is the source code for TrigSolv.java

Source

strictfp class TrigSolv {
    public static void main(String[] args) {

        double a, b, c, angleA, radA;

        // Apllying Pythagoras' Theorem
        // Obtain sides from user
        System.out.println("Side c in terms of sides a and b");
        a = 10d;
        b = 20d;
        c = Math.sqrt((a * a) + (b * b));
        System.out.println("Side c = " + c);

        // Using side/angle formula
        System.out.println("Side c in terms of side b and angle A");
        b = 30d;
        angleA = 20d;
        radA = Math.toRadians(angleA);
        c = b * Math.tan(radA);
        System.out.println("Side c = " + c);
    }
}