Calculate area and height of an isosceles triangle whose sides are radii of a circle | Java program for the above approach ; Function to convert given angle from degree to radian ; Function to calculate height and area of the triangle OAB ; Stores the angle OAB and OBA ; Stores the angle in radians ; Stores the height ; Print height of the triangle ; Stores the base of triangle OAB ; Stores the area of the triangle ; Print the area of triangle OAB ; Driver Code
import java . util . * ; class GFG { static double Convert ( double degree ) { double pi = 3.14159265359 ; return ( degree * ( pi / 180 ) ) ; } static void areaAndHeightOfTraingle ( double radius , double a ) { if ( a >= 180 a == 0 ) { System . out . println ( " Not ▁ possible " ) ; return ; } double base_angle = ( 180 - a ) / 2 ; double radians = Convert ( base_angle ) ; double height = Math . sin ( radians ) * radius ; System . out . println ( " Height ▁ of ▁ triangle ▁ " + height ) ; double Base = Math . cos ( radians ) * radius ; double area = Base * height ; System . out . println ( " Area ▁ of ▁ triangle ▁ " + area ) ; } public static void main ( String [ ] args ) { double R = 5 , angle = 120 ; areaAndHeightOfTraingle ( R , angle ) ; } }