codeparrot/xlcost-text-to-code huggingface dataset:
Area of a Triangle from the given lengths of medians | Java program to calculate area of a triangle from the given lengths of medians ; Function to return the area of triangle using medians ; Driver Code ; Function Call ; Print the final answer
class GFG { static double Area_of_Triangle ( int a , int b , int c ) { int s = ( a + b + c ) / 2 ; int x = s * ( s - a ) ; x = x * ( s - b ) ; x = x * ( s - c ) ; double area = ( 4 / ( double ) 3 ) * Math . sqrt ( x ) ; return area ; } public static void main ( String [ ] args ) { int a = 9 ; int b = 12 ; int c = 15 ; double ans = Area_of_Triangle ( a , b , c ) ; System . out . println ( ans ) ; } }
Total number of unit cells covered by all given Rectangles | Java program to find the number of cells enclosed by the given rectangles ; Update the coordinates lying within the rectangle ; Update arr [ i ] [ j ] for all ( i , j ) lying within the rectangle ; Function to return the total area covered by rectangles ; Stores the number of cells ; arr [ i ] ] [ [ j ] == 1 means that grid is filled by some rectangle ; Driver Code ; ( A [ i ] [ 0 ] , A [ i ] [ 1 ] ) denotes the coordinate of the bottom left of the rectangle ( A [ i ] [ 2 ] , A [ i ] [ 3 ] ) denotes the coordinate of upper right of the rectangle ; Update the coordinates that lie within the rectangle
class GFG { static final int MAX = 1001 ; static boolean [ ] [ ] arr = new boolean [ MAX ] [ MAX ] ; static void updateArray ( int x1 , int y1 , int x2 , int y2 ) { for ( int i = x1 ; i < x2 ; i ++ ) { for ( int j = y1 ; j < y2 ; j ++ ) { arr [ i ] [ j ] = true ; } } } static int findAreaCovered ( ) { int area = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { if ( arr [ i ] [ j ] == true ) { area ++ ; } } } return area ; } public static void main ( String [ ] args ) { int N = 3 ; int [ ] [ ] A = { { 1 , 3 , 4 , 5 } , { 3 , 1 , 7 , 4 } , { 5 , 3 , 8 , 6 } } ; for ( int i = 0 ; i < N ; i ++ ) { updateArray ( A [ i ] [ 0 ] , A [ i ] [ 1 ] , A [ i ] [ 2 ] , A [ i ] [ 3 ] ) ; } int area = findAreaCovered ( ) ; System . out . print ( area ) ; } }
Find the equation of plane which passes through two points and parallel to a given axis | Java implementation to find the equation of plane which passes through two points and parallel to a given axis ; Find direction vector of points ( x1 , y1 , z1 ) and ( x2 , y2 , z2 ) ; Values that are calculated and simplified from the cross product ; Print the equation of plane ; Driver code ; Point A ; Point B ; Given axis ; Function Call
import java . util . * ; class GFG { static void findEquation ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 , int d , int e , int f ) { double a = x2 - x1 ; double b = y2 - y1 ; double c = z2 - z1 ; int A = ( int ) ( b * f - c * e ) ; int B = ( int ) ( a * f - c * d ) ; int C = ( int ) ( a * e - b * d ) ; int D = - ( int ) ( A * d - B * e + C * f ) ; System . out . println ( A + " x ▁ + ▁ " + B + " y ▁ + ▁ " + C + " z ▁ + ▁ " + D + " = ▁ 0 ▁ " ) ; } public static void main ( String [ ] args ) { int x1 = 2 , y1 = 3 , z1 = 5 ; int x2 = 6 , y2 = 7 , z2 = 8 ; int a = 11 , b = 23 , c = 10 ; findEquation ( x1 , y1 , z1 , x2 , y2 , z2 , a , b , c ) ; } }
Find the length of the median of a Triangle if length of sides are given | Java program to find the length of the median using sides of the triangle ; Function to return the length of the median using sides of triangle ; Driver code ; Function call ; Print final answer with 2 digits after decimal
import java . util . * ; class GFG { public static float median ( int a , int b , int c ) { float n = ( float ) ( Math . sqrt ( 2 * b * b + 2 * c * c - a * a ) / 2 ) ; return n ; } public static void main ( String [ ] args ) { int a , b , c ; a = 4 ; b = 3 ; c = 5 ; float ans = median ( a , b , c ) ; System . out . println ( String . format ( " % .2f " , ans ) ) ; } }
Number of quadrilateral formed with N distinct points on circumference of Circle | Java implementation to find the number of quadrilaterals formed with N distinct points ; Function to find the number of combinations in the N ; Function to find the factorial of the given number N ; Loop to find the factorial of the given number ; Driver Code ; Function Call
class GFG { static int nCr ( int n , int r ) { return ( fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ) ; } static int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i < n + 1 ; i ++ ) res = res * i ; return res ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( nCr ( n , 4 ) ) ; } }
Length of remaining two sides of a Triangle from a given side and its adjacent angles | Java program for above approach ; Function for computing other 2 side of the trianlgle ; Computing angle C ; Converting A in to radian ; Converting B in to radian ; Converting C in to radian ; Computing length of side b ; Computing length of side c ; Driver code ; Calling function
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 ) ; } }
Minimum area of square holding two identical rectangles | Java implementation of the above approach ; Function to find the area of the square ; Larger side of rectangle ; Smaller side of the rectangle ; Driver code
import java . io . * ; class GFG { static int areaSquare ( int L , int B ) { int large = Math . max ( L , B ) ; int small = Math . min ( L , B ) ; if ( large >= 2 * small ) { return large * large ; } else { return ( 2 * small ) * ( 2 * small ) ; } } public static void main ( String [ ] args ) { int L = 7 ; int B = 4 ; System . out . println ( areaSquare ( L , B ) ) ; } }
Minimum side of square embedded in Regular polygon with N sides | Java program to find the minimum side of the square in which a regular polygon with even sides can completely embed ; PI value in Java using acos function ; Function to find the minimum side of the square in which a regular polygon with even sides can completely embed ; Projection angle variation from axes ; Projection angle variation when the number of sides are in multiple of 4 ; Distance between the end points ; Projection from all N points on X - axis ; Projection from all N points on Y - axis ; Maximum side ; Return the portion of side forming the square ; Driver code
class GFG { static double pi = Math . acos ( - 1.0 ) ; static double nGon ( int N ) { double proAngleVar ; if ( N % 4 == 0 ) { proAngleVar = pi * ( 180.0 / N ) / 180 ; } else { proAngleVar = pi * ( 180.0 / ( 2 * N ) ) / 180 ; } double negX = 1.0e+99 , posX = - 1.0e+99 , negY = 1.0e+99 , posY = - 1.0e+99 ; for ( int j = 0 ; j < N ; ++ j ) { double px = Math . cos ( 2 * pi * j / N + proAngleVar ) ; double py = Math . sin ( 2 * pi * j / N + proAngleVar ) ; negX = Math . min ( negX , px ) ; posX = Math . max ( posX , px ) ; negY = Math . min ( negY , py ) ; posY = Math . max ( posY , py ) ; } double opt2 = Math . max ( posX - negX , posY - negY ) ; return ( double ) opt2 / Math . sin ( pi / N ) / 2 ; } public static void main ( String [ ] args ) { int N = 10 ; System . out . printf ( " % .5f " , nGon ( N ) ) ; } }
Heptacontagon Number | Java program for the above approach ; Finding the nth heptacontagon number ; Driver Code
class GFG { static int heptacontagonNum ( int n ) { return ( 68 * n * n - 66 * n ) / 2 ; } public static void main ( String [ ] args ) { int N = 3 ; System . out . println ( "3rd ▁ heptacontagon ▁ Number ▁ is ▁ = ▁ " + heptacontagonNum ( N ) ) ; } }
Program to check if N is a Icositetragonal number | Java implementation to check that a number is icositetragonal number or not ; Function to check that the number is a icositetragonal number ; Condition to check if the number is a icositetragonal number ; Driver Code ; Function call
class GFG { static boolean isicositetragonal ( int N ) { float n = ( float ) ( ( 10 + Math . sqrt ( 44 * N + 100 ) ) / 22 ) ; return ( n - ( int ) n ) == 0 ; } public static void main ( String [ ] args ) { int i = 24 ; if ( isicositetragonal ( i ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }
Program to check if N is a Tridecagonal Number or not | Java implementation to check that a number is a tridecagon number or not ; Function to check that the number is a tridecagon number ; Condition to check if the number is a tridecagon number ; Driver Code ; Function call
class GFG { static boolean isTridecagon ( int N ) { float n = ( float ) ( ( 9 + Math . sqrt ( 88 * N + 81 ) ) / 22 ) ; return ( n - ( int ) n ) == 0 ; } public static void main ( String [ ] args ) { int i = 13 ; if ( isTridecagon ( i ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }
Program to check if N is a Icosihenagonal number | Java implementation to check that a number is icosihenagonal number or not ; Function to check that the number is a icosihenagonal number ; Condition to check if the number is a icosihenagonal number ; Driver Code ; Function call
class GFG { static boolean isicosihenagonal ( int N ) { float n = ( float ) ( ( 17 + Math . sqrt ( 152 * N + 289 ) ) / 38 ) ; return ( n - ( int ) n ) == 0 ; } public static void main ( String [ ] args ) { int i = 21 ; if ( isicosihenagonal ( i ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }
Program to check if N is a Icositrigonal number | Java implementation to check that a number is a icositrigonal number or not ; Function to check that the number is a icositrigonal number ; Condition to check if the number is a icositrigonal number ; Driver Code ; Function call
import java . util . * ; class GFG { static boolean isicositrigonal ( int N ) { float n = ( float ) ( 19 + Math . sqrt ( 168 * N + 361 ) ) / 42 ; return ( n - ( int ) n ) == 0 ; } public static void main ( String args [ ] ) { int i = 23 ; if ( isicositrigonal ( i ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }
Number of ways to choose K intersecting line segments on X | Java program to find Number of ways to choose K intersecting line segments on X - axis ; Function to find ( a ^ b ) % mod in log b ; Till power becomes 0 ; If power is odd ; Multiply base ; Divide power by 1 ; Function to find nCk ; Base case ; Apply formula to find nCk ; Function to find the number of ways ; sort the given lines ; Find the number of total case ; Declare a multiset ; Loop till N ; Check if smallest element is smaller than lines [ i ] ; Erase first element ; Exclude the odd cases ; Modulus operation ; Insert into multiset ; Function to precompute factorial and inverse ; Pre - compute factorial and inverse ; Driver code ; Function to pre - compute factorial and inverse
import java . util . * ; import java . lang . * ; class GFG { static long mod = 1000000007 ; static int MAXN = 1001 ; static long factorial [ ] = new long [ MAXN ] , inverse [ ] = new long [ MAXN ] ; static long power ( long a , long b ) { long res = 1 ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res * a ) % mod ; } a = ( a * a ) % mod ; b >>= 1 ; } return res ; } static long nCk ( int n , int k ) { if ( k < 0 k > n ) { return 0 ; } long ans = factorial [ n ] ; ans = ( ans * inverse [ n - k ] ) % mod ; ans = ( ans * inverse [ k ] ) % mod ; return ans ; } static void numberOfWays ( ArrayList < int [ ] > lines , int K , int N ) { Collections . sort ( lines , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; long total_case = nCk ( N , K ) ; PriorityQueue < Integer > m = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { while ( ! m . isEmpty ( ) && ( m . peek ( ) < lines . get ( i ) [ 0 ] ) ) { m . poll ( ) ; } total_case -= nCk ( m . size ( ) , K - 1 ) ; total_case += mod ; total_case %= mod ; m . add ( lines . get ( i ) [ 1 ] ) ; } System . out . println ( total_case ) ; } static void preCompute ( ) { long fact = 1 ; factorial [ 0 ] = 1 ; inverse [ 0 ] = 1 ; for ( int i = 1 ; i < MAXN ; i ++ ) { fact = ( fact * i ) % mod ; factorial [ i ] = fact ; inverse [ i ] = power ( factorial [ i ] , mod - 2 ) ; } } public static void main ( String [ ] args ) { int N = 3 , K = 2 ; ArrayList < int [ ] > lines = new ArrayList < > ( ) ; preCompute ( ) ; lines . add ( new int [ ] { 1 , 3 } ) ; lines . add ( new int [ ] { 4 , 5 } ) ; lines . add ( new int [ ] { 5 , 7 } ) ; numberOfWays ( lines , K , N ) ; } }
Check whether triangle is valid or not if three points are given | Java implementation to check if three points form a triangle ; Function to check if three points make a triangle ; Calculation the area of triangle . We have skipped multiplication with 0.5 to avoid floating point computations ; Condition to check if area is not equal to 0 ; Driver code
import java . io . * ; import java . util . * ; class GFG { static void checkTriangle ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { int a = x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ; if ( a == 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } public static void main ( String [ ] args ) { int x1 = 1 , y1 = 1 , x2 = 2 , y2 = 2 , x3 = 3 , y3 = 3 ; checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) ; } }
Total number of triplets ( A , B , C ) in which the points B and C are Equidistant to A | Java implementation to find the total number of Triplets in which the points are Equidistant ; Function to size ( ) such triplets ; Iterate over all the points ; Iterate over all points other than the current point ; Compute squared euclidean distance for the current point ; Compute nP2 that is n * ( n - 1 ) ; Return the final result ; Driver code
import java . util . * ; @ SuppressWarnings ( " unchecked " ) class GFG { static class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int numTrip ( ArrayList points ) { int res = 0 ; for ( int i = 0 ; i < points . size ( ) ; ++ i ) { HashMap < Long , Integer > map = new HashMap < > ( ) ; for ( int j = 0 ; j < points . size ( ) ; ++ j ) { if ( j == i ) continue ; int dy = ( ( pair ) points . get ( i ) ) . second - ( ( pair ) points . get ( j ) ) . second ; int dx = ( ( pair ) points . get ( i ) ) . first - ( ( pair ) points . get ( j ) ) . first ; long key = dy * dy ; key += dx * dx ; if ( map . containsKey ( key ) ) { map . put ( key , map . get ( key ) + 1 ) ; } else { map . put ( key , 1 ) ; } } for ( int p : map . values ( ) ) res += p * ( p - 1 ) ; } return res ; } public static void main ( String [ ] args ) { ArrayList mat = new ArrayList ( ) ; mat . add ( new pair ( 0 , 0 ) ) ; mat . add ( new pair ( 1 , 0 ) ) ; mat . add ( new pair ( 2 , 0 ) ) ; System . out . println ( numTrip ( mat ) ) ; } }
Check if any point overlaps the given Circle and Rectangle | Java implementation to check if any point overlaps the given circle and rectangle ; Function to check if any point overlaps the given circle and rectangle ; Find the nearest point on the rectangle to the center of the circle ; Find the distance between the nearest point and the center of the circle Distance between 2 points , ( x1 , y1 ) & ( x2 , y2 ) in 2D Euclidean space is ( ( x1 - x2 ) * * 2 + ( y1 - y2 ) * * 2 ) * * 0.5 ; Driver code
class GFG { static boolean checkOverlap ( int R , int Xc , int Yc , int X1 , int Y1 , int X2 , int Y2 ) { int Xn = Math . max ( X1 , Math . min ( Xc , X2 ) ) ; int Yn = Math . max ( Y1 , Math . min ( Yc , Y2 ) ) ; int Dx = Xn - Xc ; int Dy = Yn - Yc ; return ( Dx * Dx + Dy * Dy ) <= R * R ; } public static void main ( String [ ] args ) { int R = 1 ; int Xc = 0 , Yc = 0 ; int X1 = 1 , Y1 = - 1 ; int X2 = 3 , Y2 = 1 ; if ( checkOverlap ( R , Xc , Yc , X1 , Y1 , X2 , Y2 ) ) { System . out . print ( " True " + "NEW_LINE"); } else { System . out . print ( " False " ) ; } } }
Check if the tower of sight issue occurs or not | Java program to check if tower of sight issue occurs or not ; Function to check if point p lies in between the line joining p1 and p2 ; If parallel to X - axis ; Point p lies between p1 and p2 ; If parallel to Y - axis ; Point p lies between p1 and p2 ; If point p satisfies the equation of line joining p1 and p2 ; Function to check if tower of sight issue occurred ; B lies between AC ; D lies between AC ; A lies between BD ; C lies between BD ; Driver code ; Point A ; Point B ; Point C ; Point D
class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int checkIntersection ( pair p1 , pair p2 , pair p ) { int val ; if ( p1 . second == p2 . second && p1 . second == p . second ) { if ( p . first <= Math . max ( p1 . first , p2 . first ) && ( p . first >= Math . min ( p1 . first , p2 . first ) ) ) return 1 ; } if ( p1 . first == p2 . first && p1 . first == p . first ) { if ( p . second <= Math . max ( p1 . second , p2 . second ) && ( p . second >= Math . min ( p1 . second , p2 . second ) ) ) return 1 ; } else { val = ( p . second - p1 . second ) * ( p2 . first - p1 . first ) - ( p . first - p1 . first ) * ( p2 . second - p1 . second ) ; if ( val == 0 ) if ( ( p . first <= Math . max ( p1 . first , p2 . first ) && ( p . first >= Math . min ( p1 . first , p2 . first ) ) ) && ( p . second <= Math . max ( p1 . second , p2 . second ) && ( p . second >= Math . min ( p1 . second , p2 . second ) ) ) ) return 1 ; } return 0 ; } static void towerOfSight ( pair a , pair b , pair c , pair d ) { int flag = 0 ; if ( checkIntersection ( a , c , b ) == 1 ) flag = 1 ; else if ( checkIntersection ( a , c , d ) == 1 ) flag = 1 ; else if ( checkIntersection ( b , d , a ) == 1 ) flag = 1 ; else if ( checkIntersection ( b , d , c ) == 1 ) flag = 1 ; System . out . print ( flag == 1 ? "Yes " : " No "); } public static void main ( String [ ] args ) { pair a = new pair ( 0 , 0 ) ; pair b = new pair ( 0 , - 2 ) ; pair c = new pair ( 2 , 0 ) ; pair d = new pair ( 0 , 2 ) ; towerOfSight ( a , b , c , d ) ; } }
Number of lines from given N points not parallel to X or Y axis | Java program to find the number of lines which are formed from given N points and not parallel to X or Y axis ; Function to find the number of lines which are formed from given N points and not parallel to X or Y axis ; This will store the number of points has same x or y coordinates using the map as the value of coordinate can be very large ; Counting frequency of each x and y coordinates ; Total number of pairs can be formed ; We can not choose pairs from these as they have same x coordinatethus they will result line segment parallel to y axis ; we can not choose pairs from these as they have same y coordinate thus they will result line segment parallel to x - axis ; Return the required answer ; Driver Code ; Function call
import java . util . * ; class GFG { static int NotParallel ( int p [ ] [ ] , int n ) { HashMap < Integer , Integer > x_axis = new HashMap < Integer , Integer > ( ) ; HashMap < Integer , Integer > y_axis = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( x_axis . containsKey ( p [ i ] [ 0 ] ) ) x_axis . put ( p [ i ] [ 0 ] , x_axis . get ( p [ i ] [ 0 ] ) + 1 ) ; else x_axis . put ( p [ i ] [ 0 ] , 1 ) ; if ( y_axis . containsKey ( p [ i ] [ 1 ] ) ) y_axis . put ( p [ i ] [ 1 ] , y_axis . get ( p [ i ] [ 1 ] ) + 1 ) ; else y_axis . put ( p [ i ] [ 1 ] , 1 ) ; } int total = ( n * ( n - 1 ) ) / 2 ; for ( Map . Entry < Integer , Integer > i : x_axis . entrySet ( ) ) { int c = i . getValue ( ) ; total -= ( c * ( c - 1 ) ) / 2 ; } for ( Map . Entry < Integer , Integer > i : y_axis . entrySet ( ) ) { int c = i . getValue ( ) ; total -= ( c * ( c - 1 ) ) / 2 ; } return total ; } public static void main ( String [ ] args ) { int p [ ] [ ] = { { 1 , 2 } , { 1 , 5 } , { 1 , 15 } , { 2 , 10 } } ; int n = p . length ; System . out . print ( NotParallel ( p , n ) ) ; } }
Check whether two convex regular polygon have same center or not | Java implementation to check whether two convex polygons have same center ; Function to check whether two convex polygons have the same center or not ; Driver Code
class GFG { static int check ( int n , int m ) { if ( m % n == 0 ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } return 0 ; } public static void main ( String [ ] args ) { int n = 5 ; int m = 10 ; check ( n , m ) ; } }
Modulus of a Complex Number | Java program to find the Modulus of a Complex Number ; Function to find modulus of a complex number ; Storing the index of ' + ' ; Storing the index of ' - ' ; Finding the real part of the complex number ; Finding the imaginary part of the complex number ; Driver code
import java . util . * ; class GFG { static void findModulo ( String s ) { int l = s . length ( ) ; int i , modulus = 0 ; if ( s . contains ( " + " ) ) { i = s . indexOf ( " + " ) ; } else { i = s . indexOf ( " - " ) ; } String real = s . substring ( 0 , i ) ; String imaginary = s . substring ( i + 1 , l - 1 ) ; int x = Integer . parseInt ( real ) ; int y = Integer . parseInt ( imaginary ) ; System . out . print ( Math . sqrt ( x * x + y * y ) + "NEW_LINE"); } public static void main ( String [ ] args ) { String s = "3 + 4i " ; findModulo ( s ) ; } }
Minimum number of blocks required to form Hollow Rectangular Prism | Java Implementation to find the minimum no of blocks required to form hollow rectangular prism ; Function to display output ; Function to return minimum no of layers required to form the hollow prism ; Function to calculate no of blocks required for each layer ; No of blocks required for each row ; Check for no of layers is minimum ; Driver function ; Length , width , height of each block ; Side of one wall ; height of each wall
import java . util . * ; class GFG { static void disp ( int row_no , int block ) { System . out . print ( row_no * block ) ; } static int row ( int ht , int h ) { return ht / h ; } static void calculate ( int l , int w , int h , int a , int ht ) { int no_block = ( 4 * a ) / l ; int row_no ; if ( h < w ) row_no = row ( ht , w ) ; else row_no = row ( ht , h ) ; disp ( row_no , no_block ) ; } public static void main ( String [ ] args ) { int l = 50 , w = 20 , h = 35 ; int a = 700 ; int ht = 140 ; calculate ( l , w , h , a , ht ) ; } }
Maximum area of rectangle inscribed in an equilateral triangle | Java implementation to find the maximum area inscribed in an equilateral triangle ; Function to find the maximum area of the rectangle inscribed in an equilateral triangle of side S ; Maximum area of the rectangle inscribed in an equilateral triangle of side S ; Driver Code
class GFG { static double solve ( int s ) { double area = ( 1.732 * Math . pow ( s , 2 ) ) / 8 ; return area ; } public static void main ( String [ ] args ) { int n = 14 ; System . out . println ( solve ( n ) ) ; } }
Area of largest semicircle that can be drawn inside a square | Java program to find Area of semicircle in a square ; Function to find area of semicircle ; Driver code ; side of a square ; Call Function to find the area of semicircle
class GFG { static float find_Area ( float a ) { float R = a * ( float ) ( 2.0 - Math . sqrt ( 2 ) ) ; float area = ( float ) ( ( 3.14 * R * R ) / 2.0 ) ; return area ; } public static void main ( String [ ] args ) { float a = 4 ; System . out . println ( " ▁ Area ▁ of ▁ semicircle ▁ = ▁ " + find_Area ( a ) ) ; } }