codeparrot/xlcost-text-to-code huggingface dataset:
Angle between a Pair of Lines in 3D | Java program for the above approach ; Function to find the angle between the two lines ; Find direction ratio of line AB ; Find direction ratio of line BC ; Find the dotProduct of lines AB & BC ; Find magnitude of line AB and BC ; Find the cosine of the angle formed by line AB and BC ; Find angle in radian ; Print the angle ; Driver code ; Given coordinates Points A ; Points B ; Points C ; Function Call
import java . util . * ; class GFG { static void calculateAngle ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 , int x3 , int y3 , int z3 ) { int ABx = x1 - x2 ; int ABy = y1 - y2 ; int ABz = z1 - z2 ; int BCx = x3 - x2 ; int BCy = y3 - y2 ; int BCz = z3 - z2 ; double dotProduct = ABx * BCx + ABy * BCy + ABz * BCz ; double magnitudeAB = ABx * ABx + ABy * ABy + ABz * ABz ; double magnitudeBC = BCx * BCx + BCy * BCy + BCz * BCz ; double angle = dotProduct ; angle /= Math . sqrt ( magnitudeAB * magnitudeBC ) ; angle = ( angle * 180 ) / 3.14 ; System . out . printf ( " % .4f " , Math . abs ( angle ) ) ; } public static void main ( String [ ] args ) { int x1 = 1 , y1 = 3 , z1 = 3 ; int x2 = 3 , y2 = 4 , z2 = 5 ; int x3 = 5 , y3 = 6 , z3 = 9 ; calculateAngle ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 ) ; } }
Distance between end points of Hour and minute hand at given time | Java implementation to find the distance between the end points of the hour and minute hand ; Function to find the angle between Hour hand and minute hand ; Validate the input ; Calculate the angles moved by hour and minute hands with reference to 12 : 00 ; Find the difference between two angles ; Return the smaller angle of two possible angles ; Function to calculate cos value of angle c ; Converting degrees to radian ; Maps the sum along the series ; Holds the actual value of sin ( n ) ; Function to distance between the endpoints of the hour and minute hand ; Driver code ; Time ; Length of hour hand ; Length of minute hand ; Calling Function for finding angle between hour hand and minute hand ; Function for finding distance between end points of minute hand and hour hand
class GFG { static int calcAngle ( double h , double m ) { if ( h < 0 m < 0 h > 12 m > 60 ) System . out . printf ( " Wrong ▁ input " ) ; if ( h == 12 ) h = 0 ; if ( m == 60 ) m = 0 ; int hour_angle = ( int ) ( 0.5 * ( h * 60 + m ) ) ; int minute_angle = ( int ) ( 6 * m ) ; int angle = Math . abs ( hour_angle - minute_angle ) ; angle = Math . min ( 360 - angle , angle ) ; return angle ; } static float cal_cos ( float n ) { float accuracy = ( float ) 0.0001 , x1 , denominator , cosx , cosval ; n = ( float ) ( n * ( 3.142 / 180.0 ) ) ; x1 = 1 ; cosx = x1 ; cosval = ( float ) Math . cos ( n ) ; int i = 1 ; do { denominator = 2 * i * ( 2 * i - 1 ) ; x1 = - x1 * n * n / denominator ; cosx = cosx + x1 ; i = i + 1 ; } while ( accuracy <= Math . abs ( cosval - cosx ) ) ; return cosx ; } static float distanceEndpoints ( int a , int b , float c ) { float angle = cal_cos ( c ) ; return ( float ) Math . sqrt ( ( a * a ) + ( b * b ) - 2 * a * b * angle ) ; } public static void main ( String [ ] args ) { int hour = 3 ; int min = 30 ; int hourHand = 3 ; int minHand = 4 ; double angle = calcAngle ( hour , min ) ; float distance = distanceEndpoints ( minHand , hourHand , ( long ) angle ) ; System . out . printf ( " % .5f " , distance ) ; } }
Pentadecagonal Number | Java program to find Nth pentadecagonal number ; Function to find N - th pentadecagonal number ; Formula to calculate nth Pentadecagonal number ; Driver code
import java . io . * ; import java . util . * ; class GFG { static int Pentadecagonal_num ( int n ) { return ( 13 * n * n - 11 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( Pentadecagonal_num ( n ) ) ; n = 10 ; System . out . println ( Pentadecagonal_num ( n ) ) ; } }
Octadecagonal Number | Java program to find Nth octadecagonal number ; Function to find N - th octadecagonal number ; Formula to calculate nth octadecagonal number ; Driver code
import java . io . * ; import java . util . * ; class GFG { static int Octadecagonal_num ( int n ) { return ( 16 * n * n - 14 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( Octadecagonal_num ( n ) ) ; n = 10 ; System . out . println ( Octadecagonal_num ( n ) ) ; } }
Icositrigonal Number | Java program to find nth Icositrigonal number ; Function to find N - th Icositrigonal number ; Formula to calculate nth Icositrigonal number ; Driver code
class GFG { static int IcositrigonalNum ( int n ) { return ( 21 * n * n - 19 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( IcositrigonalNum ( n ) + "NEW_LINE"); n = 10 ; System . out . print ( IcositrigonalNum ( n ) ) ; } }
Find the percentage change in the area of a Rectangle | Java implementation to find the percentage ; Function to calculate percentage change in area of rectangle ; Driver code
import java . util . * ; class GFG { static int calculate_change ( int length , int breadth ) { int change = 0 ; change = length + breadth + ( ( length * breadth ) / 100 ) ; return change ; } public static void main ( String args [ ] ) { int cL = 20 ; int cB = - 10 ; int cA = calculate_change ( cL , cB ) ; System . out . println ( + cA ) ; } }
Minimum number of Circular obstacles required to obstruct the path in a Grid | Java program to find the minimum number of obstacles required ; Function to find the minimum number of obstacles required ; Find the minimum range required to put obstacles ; Sorting the radius ; If val is less than zero then we have find the number of obstacles required ; Driver code
import java . util . * ; class GFG { static int solve ( int n , int m , int obstacles , double range [ ] ) { double val = Math . min ( n , m ) ; Arrays . sort ( range ) ; int c = 1 ; for ( int i = obstacles - 1 ; i >= 0 ; i -- ) { range [ i ] = 2 * range [ i ] ; val -= range [ i ] ; if ( val <= 0 ) { return c ; } else { c ++ ; } } if ( val > 0 ) { return - 1 ; } return 0 ; } public static void main ( String [ ] args ) { int n = 4 , m = 5 , obstacles = 3 ; double range [ ] = { 1.0 , 1.25 , 1.15 } ; System . out . print ( solve ( n , m , obstacles , range ) + "NEW_LINE"); } }
Program to calculate area of a rhombus whose one side and diagonal are given | Java program to calculate the area of a rhombus whose one side and one diagonal is given ; function to calculate the area of the rhombus ; Second diagonal ; area of rhombus ; return the area ; Driver code
class GFG { static double area ( double d1 , double a ) { double d2 = Math . sqrt ( 4 * ( a * a ) - d1 * d1 ) ; double area = 0.5 * d1 * d2 ; return area ; } public static void main ( String [ ] args ) { double d = 7.07 ; double a = 5 ; System . out . println ( area ( d , a ) ) ; } }
Check whether two points ( x1 , y1 ) and ( x2 , y2 ) lie on same side of a given line or not | Java program to check if two points lie on the same side or not ; Function to check if two points lie on the same side or not ; int fx1 ; Variable to store a * x1 + b * y1 - c int fx2 ; Variable to store a * x2 + b * y2 - c ; If fx1 and fx2 have same sign ; Driver code
import java . util . * ; class GFG { static boolean pointsAreOnSameSideOfLine ( int a , int b , int c , int x1 , int y1 , int x2 , int y2 ) { fx1 = a * x1 + b * y1 - c ; fx2 = a * x2 + b * y2 - c ; if ( ( fx1 * fx2 ) > 0 ) return true ; return false ; } public static void main ( String [ ] args ) { int a = 1 , b = 1 , c = 1 ; int x1 = 1 , y1 = 1 ; int x2 = 2 , y2 = 1 ; if ( pointsAreOnSameSideOfLine ( a , b , c , x1 , y1 , x2 , y2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Percentage increase in volume of the cube if a side of cube is increased by a given percentage | Java program to find percentage increase in the volume of the cube if a side of cube is increased by a given percentage ; Driver code
import java . io . * ; class GFG { static void newvol ( double x ) { System . out . print ( " percentage ▁ increase ▁ " + " in ▁ the ▁ volume ▁ of ▁ the ▁ cube ▁ is ▁ " + ( Math . pow ( x , 3 ) / 10000 + 3 * x + ( 3 * Math . pow ( x , 2 ) ) / 100 ) ) ; System . out . print ( " % " ) ; } public static void main ( String [ ] args ) { double x = 10 ; newvol ( x ) ; } }
Number of triangles formed by joining vertices of n | Java program to implement the above problem ; Function to find the number of triangles ; print the number of triangles having two side common ; print the number of triangles having no side common ; Driver code ; initialize the number of sides of a polygon
import java . io . * ; class GFG { static void findTriangles ( int n ) { int num = n ; System . out . print ( num + " ▁ " ) ; System . out . print ( num * ( num - 4 ) * ( num - 5 ) / 6 ) ; } public static void main ( String [ ] args ) { int n ; n = 6 ; findTriangles ( n ) ; } }
Find the radii of the circles which are lined in a row , and distance between the centers of first and last circle is given | Java program to find radii of the circles which are lined in a row and distance between the centers of first and last circle is given ; Driver code
import java . io . * ; class GFG { static void radius ( int n , int d ) { System . out . print ( " The ▁ radius ▁ of ▁ each ▁ circle ▁ is ▁ " + d / ( 2 * n - 2 ) ) ; } static public void main ( String [ ] args ) { int d = 42 , n = 4 ; radius ( n , d ) ; } }
Find the side of the squares which are lined in a row , and distance between the centers of first and last square is given | Java program to find side of the squares which are lined in a row and distance between the centers of first and last squares is given ; Driver code
import java . io . * ; class GFG { static void radius ( int n , int d ) { System . out . print ( " The ▁ side ▁ of ▁ each ▁ square ▁ is ▁ " + d / ( n - 1 ) ) ; } public static void main ( String [ ] args ) { int d = 42 , n = 4 ; radius ( n , d ) ; } }
Number of triangles formed by joining vertices of n | Java program to implement the above problem ; Function to find the number of triangles ; print the number of triangles ; Driver code ; initialize the number of sides of a polygon
class GFG { static void findTriangles ( int n ) { int num ; num = n * ( n - 4 ) ; System . out . println ( num ) ; } public static void main ( String [ ] args ) { int n ; n = 6 ; findTriangles ( n ) ; } }
Find the Diameter or Longest chord of a Circle | Java program to find the longest chord or diameter of the circle whose radius is given ; Function to find the longest chord ; Driver code ; Get the radius ; Find the diameter
class GFG { static void diameter ( double r ) { System . out . println ( " The ▁ length ▁ of ▁ the ▁ longest ▁ chord " + " ▁ or ▁ diameter ▁ of ▁ the ▁ circle ▁ is ▁ " + 2 * r ) ; } public static void main ( String [ ] args ) { double r = 4 ; diameter ( r ) ; } }
Slope of the line parallel to the line with the given slope | Java implementation of the approach ; Function to return the slope of the line which is parallel to the line with the given slope ; Driver code
class GfG { static double getSlope ( double m ) { return m ; } public static void main ( String [ ] args ) { double m = 2 ; System . out . println ( getSlope ( m ) ) ; } }
Total number of triangles formed when there are H horizontal and V vertical lines | Java implementation of the approach ; Function to return total triangles ; Only possible triangle is the given triangle ; If only vertical lines are present ; If only horizontal lines are present ; Return total triangles ; Driver code
class GFG { public static int totalTriangles ( int h , int v ) { if ( h == 0 && v == 0 ) return 1 ; if ( h == 0 ) return ( ( v + 1 ) * ( v + 2 ) / 2 ) ; if ( v == 0 ) return ( h + 1 ) ; int total = ( h + 1 ) * ( ( v + 1 ) * ( v + 2 ) / 2 ) ; return total ; } public static void main ( String [ ] args ) { int h = 2 , v = 2 ; System . out . print ( totalTriangles ( h , v ) ) ; } }
Largest sphere that can be inscribed in a right circular cylinder inscribed in a frustum | Java Program to find the biggest sphere that can be inscribed within a right circular cylinder which in turn is inscribed within a frustum ; Function to find the biggest sphere ; the radii and height cannot be negative ; radius of the sphere ; volume of the sphere ; Driver code
import java . lang . Math ; class gfg { static float sph ( float r , float R , float h ) { if ( r < 0 && R < 0 && h < 0 ) return - 1 ; float x = r ; float V = ( float ) ( 4 * 3.14f * Math . pow ( r , 3 ) ) / 3 ; return V ; } public static void main ( String [ ] args ) { float r = 5 , R = 8 , h = 11 ; System . out . println ( sph ( r , R , h ) ) ; } }
Check whether two straight lines are orthogonal or not | Java implementation of above approach ; Function to check if two straight lines are orthogonal or not ; Both lines have infinite slope ; Only line 1 has infinite slope ; Only line 2 has infinite slope ; Find slopes of the lines ; Check if their product is - 1 ; Driver code
import java . io . * ; class GFG { static boolean checkOrtho ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 , int x4 , int y4 ) { int m1 , m2 ; if ( x2 - x1 == 0 && x4 - x3 == 0 ) return false ; else if ( x2 - x1 == 0 ) { m2 = ( y4 - y3 ) / ( x4 - x3 ) ; if ( m2 == 0 ) return true ; else return false ; } else if ( x4 - x3 == 0 ) { m1 = ( y2 - y1 ) / ( x2 - x1 ) ; if ( m1 == 0 ) return true ; else return false ; } else { m1 = ( y2 - y1 ) / ( x2 - x1 ) ; m2 = ( y4 - y3 ) / ( x4 - x3 ) ; if ( m1 * m2 == - 1 ) return true ; else return false ; } } public static void main ( String [ ] args ) { int x1 = 0 , y1 = 4 , x2 = 0 , y2 = - 9 ; int x3 = 2 , y3 = 0 , x4 = - 1 , y4 = 0 ; if ( checkOrtho ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Diagonal of a Regular Pentagon | Java Program to find the diagonal of a regular pentagon ; Function to find the diagonal of a regular pentagon ; Side cannot be negative ; Length of the diagonal ; Driver code
class GFG { static double pentdiagonal ( double a ) { if ( a < 0 ) return - 1 ; double d = 1.22 * a ; return d ; } static public void main ( String args [ ] ) { double a = 6 ; System . out . println ( pentdiagonal ( a ) ) ; } }
Area of hexagon with given diagonal length | Java program to find the area of Hexagon with given diagonal ; Function to calculate area ; Formula to find area ; Main
import java . lang . Math ; public class GfG { public static float hexagonArea ( float d ) { return ( float ) ( ( 3 * Math . sqrt ( 3 ) * d * d ) / 8 ) ; } public static void main ( String [ ] args ) { float d = 10 ; System . out . println ( " Area ▁ of ▁ hexagon : ▁ " + hexagonArea ( d ) ) ; } }
Number of squares of side length required to cover an N * M rectangle | Java program to find number of squares of a * a required to cover n * m rectangle ; function to find a number of squares of a * a required to cover n * m rectangle ; Driver code ; function call
import java . util . * ; class solution { static int Squares ( int n , int m , int a ) { return ( ( m + a - 1 ) / a ) * ( ( n + a - 1 ) / a ) ; } public static void main ( String arr [ ] ) { int n = 6 , m = 6 , a = 4 ; System . out . println ( Squares ( n , m , a ) ) ; } }
Length of the Diagonal of the Octagon | Java Program to find the diagonal of the octagon ; Function to find the diagonal of the octagon ; side cannot be negative ; diagonal of the octagon ; Driver code
import java . util . * ; class solution { static double octadiagonal ( double a ) { if ( a < 0 ) return - 1 ; return a * Math . sqrt ( 4 + ( 2 * Math . sqrt ( 2 ) ) ) ; } public static void main ( String args [ ] ) { double a = 4 ; System . out . println ( octadiagonal ( a ) ) ; } }
Program to Calculate the Perimeter of a Decagon | package whatever do not write package name here Java program to Calculate the Perimeter of a Decagon ; Function for finding the perimeter ; Driver code
import java . io . * ; class GFG { static void CalPeri ( ) { int S = 5 , Perimeter ; Perimeter = 10 * S ; System . out . println ( " The ▁ Perimeter ▁ of ▁ Decagon ▁ is ▁ : ▁ " + Perimeter ) ; } public static void main ( String [ ] args ) { CalPeri ( ) ; } }
Sum of lengths of all 12 edges of any rectangular parallelepiped | Java program to illustrate the above problem ; function to find the sum of all the edges of parallelepiped ; to calculate the length of one edge ; sum of all the edges of one side ; net sum will be equal to the summation of edges of all the sides ; Driver code ; initialize the area of three faces which has a common vertex
import java . io . * ; class GFG { static double findEdges ( double s1 , double s2 , double s3 ) { double a = Math . sqrt ( s1 * s2 / s3 ) ; double b = Math . sqrt ( s3 * s1 / s2 ) ; double c = Math . sqrt ( s3 * s2 / s1 ) ; double sum = a + b + c ; return 4 * sum ; } public static void main ( String [ ] args ) { double s1 , s2 , s3 ; s1 = 65 ; s2 = 156 ; s3 = 60 ; System . out . print ( findEdges ( s1 , s2 , s3 ) ) ; } }
Maximum number of pieces in N cuts | Java program to find maximum no of pieces by given number of cuts ; Function for finding maximum pieces with n cuts . ; to maximize number of pieces x is the horizontal cuts ; Now ( x ) is the horizontal cuts and ( n - x ) is vertical cuts , then maximum number of pieces = ( x + 1 ) * ( n - x + 1 ) ; Driver code ; Taking the maximum number of cuts allowed as 3 ; Finding and printing the max number of pieces
import java . util . * ; class GFG { public static int findMaximumPieces ( int n ) { int x = n / 2 ; return ( ( x + 1 ) * ( n - x + 1 ) ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( " Max ▁ number ▁ of ▁ pieces ▁ for ▁ n ▁ = ▁ " + n + " ▁ is ▁ " + findMaximumPieces ( 3 ) ) ; } }
Program to check whether 4 points in a 3 | Java program to check if 4 points in a 3 - D plane are Coplanar ; Function to find equation of plane . ; checking if the 4 th point satisfies the above equation ; Driver Code ; function calling
public class GFG { static void equation_plane ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 , int x3 , int y3 , int z3 , int x , int y , int z ) { int a1 = x2 - x1 ; int b1 = y2 - y1 ; int c1 = z2 - z1 ; int a2 = x3 - x1 ; int b2 = y3 - y1 ; int c2 = z3 - z1 ; int a = b1 * c2 - b2 * c1 ; int b = a2 * c1 - a1 * c2 ; int c = a1 * b2 - b1 * a2 ; int d = ( - a * x1 - b * y1 - c * z1 ) ; if ( a * x + b * y + c * z + d == 0 ) System . out . println ( " Coplanar " ) ; else System . out . println ( " Not ▁ Coplanar " ) ; } public static void main ( String [ ] args ) { int x1 = 3 ; int y1 = 2 ; int z1 = - 5 ; int x2 = - 1 ; int y2 = 4 ; int z2 = - 3 ; int x3 = - 3 ; int y3 = 8 ; int z3 = - 5 ; int x4 = - 3 ; int y4 = 2 ; int z4 = 1 ; equation_plane ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 , x4 , y4 , z4 ) ; } }
Angle between two Planes in 3D | Java program to find the Angle between two Planes in 3 D . ; Function to find Angle ; Driver code
import java . io . * ; import java . lang . Math ; class GFG { static void distance ( float a1 , float b1 , float c1 , float a2 , float b2 , float c2 ) { float d = ( a1 * a2 + b1 * b2 + c1 * c2 ) ; float e1 = ( float ) Math . sqrt ( a1 * a1 + b1 * b1 + c1 * c1 ) ; float e2 = ( float ) Math . sqrt ( a2 * a2 + b2 * b2 + c2 * c2 ) ; d = d / ( e1 * e2 ) ; float pi = ( float ) 3.14159 ; float A = ( 180 / pi ) * ( float ) ( Math . acos ( d ) ) ; System . out . println ( " Angle ▁ is ▁ " + A + " ▁ degree " ) ; } public static void main ( String [ ] args ) { float a1 = 1 ; float b1 = 1 ; float c1 = 2 ; float d1 = 1 ; float a2 = 2 ; float b2 = - 1 ; float c2 = 1 ; float d2 = - 4 ; distance ( a1 , b1 , c1 , a2 , b2 , c2 ) ; } }
Mirror of a point through a 3 D plane | Java program to find Mirror of a point through a 3 D plane ; Function to mirror image ; Driver Code ; function call
import java . io . * ; class GFG { static void mirror_point ( int a , int b , int c , int d , int x1 , int y1 , int z1 ) { float k = ( - a * x1 - b * y1 - c * z1 - d ) / ( float ) ( a * a + b * b + c * c ) ; float x2 = a * k + x1 ; float y2 = b * k + y1 ; float z2 = c * k + z1 ; float x3 = 2 * x2 - x1 ; float y3 = 2 * y2 - y1 ; float z3 = 2 * z2 - z1 ; System . out . print ( " x3 ▁ = ▁ " + x3 + " ▁ " ) ; System . out . print ( " y3 ▁ = ▁ " + y3 + " ▁ " ) ; System . out . print ( " z3 ▁ = ▁ " + z3 + " ▁ " ) ; } public static void main ( String [ ] args ) { int a = 1 ; int b = - 2 ; int c = 0 ; int d = 0 ; int x1 = - 1 ; int y1 = 3 ; int z1 = 4 ; mirror_point ( a , b , c , d , x1 , y1 , z1 ) ; } }
Number of rectangles in a circle of radius R | Java program to find the number of rectangles that can be cut from a circle of Radius R ; Function to return the total possible rectangles that can be cut from the circle ; Diameter = 2 * Radius ; Square of diameter which is the square of the maximum length diagonal ; generate all combinations of a and b in the range ( 1 , ( 2 * Radius - 1 ) ) ( Both inclusive ) ; Calculate the Diagonal length of this rectangle ; If this rectangle 's Diagonal  Length is less than the Diameter,  it is a valid rectangle, thus  increment counter ; Driver Code ; Radius of the circle
import java . io . * ; class GFG { static int countRectangles ( int radius ) { int rectangles = 0 ; int diameter = 2 * radius ; int diameterSquare = diameter * diameter ; for ( int a = 1 ; a < 2 * radius ; a ++ ) { for ( int b = 1 ; b < 2 * radius ; b ++ ) { int diagonalLengthSquare = ( a * a + b * b ) ; if ( diagonalLengthSquare <= diameterSquare ) { rectangles ++ ; } } } return rectangles ; } public static void main ( String [ ] args ) { int radius = 2 ; int totalRectangles ; totalRectangles = countRectangles ( radius ) ; System . out . println ( totalRectangles + " ▁ rectangles ▁ can ▁ be ▁ " + " cut ▁ from ▁ a ▁ circle ▁ of " + " ▁ Radius ▁ " + radius ) ; } }
Program to check similarity of given two triangles | Java program to check similarity between two triangles . ; Function for AAA similarity ; Check for AAA ; Function for SAS similarity ; angle b / w two smallest sides is largest . ; since we take angle b / w the sides . ; Function for SSS similarity ; Check for SSS ; Driver Code ; function call for AAA similarity ; function call for SSS similarity ; function call for SAS similarity ; Check if triangles are similar or not
import java . util . * ; class GFG1 { static int simi_aaa ( int a1 [ ] , int a2 [ ] ) { Arrays . sort ( a1 ) ; Arrays . sort ( a2 ) ; if ( a1 [ 0 ] == a2 [ 0 ] && a1 [ 1 ] == a2 [ 1 ] && a1 [ 2 ] == a2 [ 2 ] ) return 1 ; else return 0 ; } static int simi_sas ( int s1 [ ] , int s2 [ ] , int a1 [ ] , int a2 [ ] ) { Arrays . sort ( a1 ) ; Arrays . sort ( a2 ) ; Arrays . sort ( s1 ) ; Arrays . sort ( s2 ) ; if ( s1 [ 0 ] / s2 [ 0 ] == s1 [ 1 ] / s2 [ 1 ] ) { if ( a1 [ 2 ] == a2 [ 2 ] ) return 1 ; } if ( s1 [ 1 ] / s2 [ 1 ] == s1 [ 2 ] / s2 [ 2 ] ) { if ( a1 [ 0 ] == a2 [ 0 ] ) return 1 ; } if ( s1 [ 2 ] / s2 [ 2 ] == s1 [ 0 ] / s2 [ 0 ] ) { if ( a1 [ 1 ] == a2 [ 1 ] ) return 1 ; } return 0 ; } static int simi_sss ( int s1 [ ] , int s2 [ ] ) { Arrays . sort ( s1 ) ; Arrays . sort ( s2 ) ; if ( s1 [ 0 ] / s2 [ 0 ] == s1 [ 1 ] / s2 [ 1 ] && s1 [ 1 ] / s2 [ 1 ] == s1 [ 2 ] / s2 [ 2 ] && s1 [ 2 ] / s2 [ 2 ] == s1 [ 0 ] / s2 [ 0 ] ) return 1 ; return 0 ; } public static void main ( String args [ ] ) { int s1 [ ] = { 2 , 3 , 3 } ; int s2 [ ] = { 4 , 6 , 6 } ; int a1 [ ] = { 80 , 60 , 40 } ; int a2 [ ] = { 40 , 60 , 80 } ; int aaa = simi_aaa ( a1 , a2 ) ; int sss = simi_sss ( s1 , s2 ) ; int sas = simi_sas ( s1 , s2 , a1 , a2 ) ; if ( aaa == 1 sss == 1 sas == 1 ) { System . out . print ( " Triangles ▁ are ▁ " + " similar ▁ by ▁ " ) ; if ( aaa == 1 ) System . out . print ( " AAA ▁ " ) ; if ( sss == 1 ) System . out . print ( " SSS ▁ " ) ; if ( sas == 1 ) System . out . print ( " SAS . " ) ; } else System . out . println ( " Triangles ▁ are ▁ " + " not ▁ similar " ) ; } }