Program to find area of a Circular Segment | Java Program to find area of segment of a circle ; Function to find area of segment ; Calculating area of sector ; Calculating area of triangle ; Driver Function
class GFG { static float pi = 3.14159f ; static float area_of_segment ( float radius , float angle ) { float area_of_sector = pi * ( radius * radius ) * ( angle / 360 ) ; float area_of_triangle = ( float ) 1 / 2 * ( radius * radius ) * ( float ) Math . sin ( ( angle * pi ) / 180 ) ; return area_of_sector - area_of_triangle ; } public static void main ( String [ ] args ) { float radius = 10.0f , angle = 90.0f ; System . out . println ( " Area ▁ of ▁ minor ▁ segment ▁ = ▁ " + area_of_segment ( radius , angle ) ) ; System . out . println ( " Area ▁ of ▁ major ▁ segment ▁ = ▁ " + area_of_segment ( radius , ( 360 - angle ) ) ) ; } }