Largest square that can be inscribed in a semicircle | Java Program to find the biggest square which can be inscribed within the semicircle ; Function to find the area of the square ; the radius cannot be negative ; area of the square ; Driver code
import java . io . * ; class GFG { static float squarearea ( float r ) { if ( r < 0 ) return - 1 ; float a = 4 * ( float ) ( Math . pow ( r , 2 ) / 5 ) ; return a ; } public static void main ( String [ ] args ) { float r = 5 ; System . out . println ( squarearea ( r ) ) ; } }