calculate length of a triangle side if two side’s length are given in Java

Given the length of a side a of a triangle and its adjacent angles B and C, the task is to find the remaining two sides of the triangle.The length and the area of the triangle side it can be between them in theradius and the length in a traingle and it can be calculated by using side angle side method in rhe length of the traingle.

code

import java.util.*;


class GFG{
static void findSide(double a, double B,
                     double C)
{
    double A = 180 - C - B;
    double radA = (Math.PI * (A / 180));
    double radB = (Math.PI * (B / 180));
    double radC = (Math.PI * (C / 180));
    double b = (a / Math.sin(radA) *
                    Math.sin(radB));
    double c = (a / Math.sin(radA) *
                    Math.sin(radC));
    
    System.out.printf("%.15f", b);
    System.out.printf(" %.15f", c);
}


public static void main(String[] args)
{
    int a = 12, B = 60, C = 30;
    findSide(a, B, C);
}
}
output:-
10.392304845413264 5.999999999999999
Time Complexity: O(1) 
Auxiliary Space: O(1)  

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top