codeparrot/xlcost-text-to-code huggingface dataset:
Minimum number of square tiles required to fill the rectangular floor | Java implementation of above approach ; Function to find the number of tiles ; no of tiles ; Driver Code ; input length and breadth of rectangle and side of square
class GFG { static int solve ( double M , double N , double s ) { int ans = ( ( int ) ( Math . ceil ( M / s ) ) * ( int ) ( Math . ceil ( N / s ) ) ) ; return ans ; } public static void main ( String [ ] args ) { double N = 12 , M = 13 , s = 4 ; System . out . println ( solve ( M , N , s ) ) ; } }
Program to find equation of a plane passing through 3 points | Java program to find equation of a plane passing through given 3 points . ; Function to find equation of plane . ; Driver code
import java . io . * ; class GFG { static void equation_plane ( float x1 , float y1 , float z1 , float x2 , float y2 , float z2 , float x3 , float y3 , float z3 ) { float a1 = x2 - x1 ; float b1 = y2 - y1 ; float c1 = z2 - z1 ; float a2 = x3 - x1 ; float b2 = y3 - y1 ; float c2 = z3 - z1 ; float a = b1 * c2 - b2 * c1 ; float b = a2 * c1 - a1 * c2 ; float c = a1 * b2 - b1 * a2 ; float d = ( - a * x1 - b * y1 - c * z1 ) ; System . out . println ( " equation ▁ of ▁ plane ▁ is ▁ " + a + " ▁ x ▁ + ▁ " + b + " ▁ y ▁ + ▁ " + c + " ▁ z ▁ + ▁ " + d + " ▁ = ▁ 0 . " ) ; } public static void main ( String [ ] args ) { float x1 = - 1 ; float y1 = 2 ; float z1 = 1 ; float x2 = 0 ; float y2 = - 3 ; float z2 = 2 ; float x3 = 1 ; float y3 = 1 ; float z3 = - 4 ; equation_plane ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 ) ; } }
Perpendicular distance between a point and a Line in 2 D | Java program to find the distance between a given point and a given line in 2 D . ; Function to find distance ; Driver code
import java . io . * ; class GFG { static void shortest_distance ( float x1 , float y1 , float a , float b , float c ) { double d = Math . abs ( ( ( a * x1 + b * y1 + c ) ) / ( Math . sqrt ( a * a + b * b ) ) ) ; System . out . println ( " Perpendicular ▁ " + " distance ▁ is ▁ " + d ) ; return ; } public static void main ( String [ ] args ) { float x1 = 5 ; float y1 = 6 ; float a = - 2 ; float b = 3 ; float c = 4 ; shortest_distance ( x1 , y1 , a , b , c ) ; } }
Program to determine the octant of the axial plane | Java program to print octant of a given point . ; Function to print octant ; Driver Code
import java . util . * ; class solution { static void octant ( float x , float y , float z ) { if ( x >= 0 && y >= 0 && z >= 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 1st ▁ octant " ) ; else if ( x < 0 && y >= 0 && z >= 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 2nd ▁ octant " ) ; else if ( x < 0 && y < 0 && z >= 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 3rd ▁ octant " ) ; else if ( x >= 0 && y < 0 && z >= 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 4th ▁ octant " ) ; else if ( x >= 0 && y >= 0 && z < 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 5th ▁ octant " ) ; else if ( x < 0 && y >= 0 && z < 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 6th ▁ octant " ) ; else if ( x < 0 && y < 0 && z < 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 7th ▁ octant " ) ; else if ( x >= 0 && y < 0 && z < 0 ) System . out . println ( " Point ▁ lies ▁ in ▁ 8th ▁ octant " ) ; } public static void main ( String args [ ] ) { float x = 2 , y = 3 , z = 4 ; octant ( x , y , z ) ; x = - 4 ; y = 2 ; z = - 8 ; octant ( x , y , z ) ; x = - 6 ; y = - 2 ; z = 8 ; octant ( x , y , z ) ; } }
Number of triangles in a plane if no more than two points are collinear | Java program to find the number of triangles in a plane if no more then two points are collinear . ; Function to find number of triangles in a plane . ; Formula to find number of triangle nC3 = n * ( n - 1 ) * ( n - 2 ) / 6 ; Driver code
import java . io . * ; class GFG { static int countNumberOfTriangles ( int n ) { return n * ( n - 1 ) * ( n - 2 ) / 6 ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( countNumberOfTriangles ( n ) ) ; } }
Centered Dodecagonal Number | Java Program to find nth centered dodecagonal number ; Function to calculate centered dodecagonal number ; Formula to calculate nth centered dodecagonal number ; Driver Code
import java . io . * ; class GFG { static long centeredDodecagonal ( long n ) { return 6 * n * ( n - 1 ) + 1 ; } public static void main ( String [ ] args ) { long n = 2 ; System . out . println ( centeredDodecagonal ( n ) ) ; n = 9 ; System . out . println ( centeredDodecagonal ( n ) ) ; } }
Centered tridecagonal number | Java Program to find nth centered tridecagonal number ; Function to find nth centered tridecagonal number ; Formula to calculate nth centered tridecagonal number ; Driver Code
import java . io . * ; class GFG { static long centeredTridecagonalNum ( long n ) { return ( 13 * n * ( n - 1 ) + 2 ) / 2 ; } public static void main ( String [ ] args ) { long n = 3 ; System . out . println ( centeredTridecagonalNum ( n ) ) ; n = 10 ; System . out . println ( centeredTridecagonalNum ( n ) ) ; } }
Pentagonal Pyramidal Number | Java Program to get nth Pentagonal pyramidal number . ; function to get nth Pentagonal pyramidal number . ; Running loop from 1 to n ; get nth pentagonal number ; add to sum ; Driver Code
import java . io . * ; class GFG { static int pentagon_pyramidal ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int p = ( 3 * i * i - i ) / 2 ; sum = sum + p ; } return sum ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( pentagon_pyramidal ( n ) ) ; } }
Pentagonal Pyramidal Number | Java Program to get nth Pentagonal pyramidal number . ; function to get nth Pentagonal pyramidal number . ; Driver Code
import java . io . * ; class GFG { static int pentagon_pyramidal ( int n ) { return n * n * ( n + 1 ) / 2 ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( pentagon_pyramidal ( n ) ) ; } }
Check if three straight lines are concurrent or not | Java Program to check if three straight line are concurrent or no ; Return true if three line are concurrent , else false . ; Driven Program
import java . io . * ; class GFG { static boolean checkConcurrent ( int a1 , int b1 , int c1 , int a2 , int b2 , int c2 , int a3 , int b3 , int c3 ) { return ( a3 * ( b1 * c2 - b2 * c1 ) + b3 * ( c1 * a2 - c2 * a1 ) + c3 * ( a1 * b2 - a2 * b1 ) == 0 ) ; } public static void main ( String [ ] args ) { int a1 = 2 , b1 = - 3 , c1 = 5 ; int a2 = 3 , b2 = 4 , c2 = - 7 ; int a3 = 9 , b3 = - 5 , c3 = 8 ; if ( checkConcurrent ( a1 , b1 , c1 , a2 , b2 , c2 , a3 , b3 , c3 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Centered Octadecagonal Number | Java Program to find the nth centered octadecagonal number ; centered octadecagon function ; Formula to calculate nth centered octadecagonal number ; Driver Code
import java . io . * ; class GFG { static int center_octadecagon_num ( int n ) { return 9 * n * n - 9 * n + 1 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( n + " th ▁ centered ▁ " + " octadecagonal ▁ number ▁ : ▁ " ) ; System . out . println ( center_octadecagon_num ( n ) ) ; n = 13 ; System . out . print ( n + " th ▁ centered ▁ " + " octadecagonal ▁ number ▁ : ▁ " ) ; System . out . println ( center_octadecagon_num ( n ) ) ; } }
Centered decagonal number | Java Program to find nth centered decagonal number ; Centered decagonal number function ; Formula to calculate nth centered decagonal number & return it into main function . ; Driver Code
import java . io . * ; class GFG { static int centereddecagonalnum ( int n ) { return ( 5 * n * n + 5 * n + 1 ) ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( n + " th ▁ centered ▁ " + " decagonal ▁ number : ▁ " ) ; System . out . println ( centereddecagonalnum ( n ) ) ; n = 9 ; System . out . print ( n + " th ▁ centered ▁ " + " decagonal ▁ number : ▁ " ) ; System . out . println ( centereddecagonalnum ( n ) ) ; } }
Lexicographically Kth smallest way to reach given coordinate from origin | Java Program to find Lexicographically Kth smallest way to reach given coordinate from origin ; Return ( a + b ) ! / a ! b ! ; finding ( a + b ) ! ; finding ( a + b ) ! / a ! ; finding ( a + b ) ! / b ! ; Return the Kth smallest way to reach given coordinate from origin ; if at origin ; if on y - axis ; decrement y . ; Move vertical ; recursive call to take next step . ; If on x - axis ; decrement x . ; Move horizontal . ; recursive call to take next step . ; If x + y C x is greater than K ; Move Horizontal ; recursive call to take next step . ; Move vertical ; recursive call to take next step . ; Driver Code
import java . io . * ; class GFG { static int factorial ( int a , int b ) { int res = 1 ; for ( int i = 1 ; i <= ( a + b ) ; i ++ ) res = res * i ; for ( int i = 1 ; i <= a ; i ++ ) res = res / i ; for ( int i = 1 ; i <= b ; i ++ ) res = res / i ; return res ; } static void Ksmallest ( int x , int y , int k ) { if ( x == 0 && y == 0 ) return ; else if ( x == 0 ) { y -- ; System . out . print ( " V " ) ; Ksmallest ( x , y , k ) ; } else if ( y == 0 ) { x -- ; System . out . print ( " H " ) ; Ksmallest ( x , y , k ) ; } else { if ( factorial ( x - 1 , y ) > k ) { System . out . print ( " H " ) ; Ksmallest ( x - 1 , y , k ) ; } else { System . out . print ( " V " ) ; Ksmallest ( x , y - 1 , k - factorial ( x - 1 , y ) ) ; } } } public static void main ( String [ ] args ) { int x = 2 , y = 2 , k = 2 ; Ksmallest ( x , y , k ) ; } }
Centered pentagonal number | Program to find nth Centered pentagonal number ; centered pentagonal number function ; Formula to calculate nth Centered pentagonal number and return it into main function . ; Driver Code
import java . io . * ; class GFG { static int centered_pentagonal_Num ( int n ) { return ( 5 * n * n - 5 * n + 2 ) / 2 ; } public static void main ( String [ ] args ) { int n = 7 ; System . out . print ( n + " th ▁ Centered ▁ " + " pentagonal ▁ number : ▁ " ) ; System . out . println ( centered_pentagonal_Num ( n ) ) ; } }
Find maximum and minimum distance between magnets | Java program for max and min distance ; Function for finding distance between pivots ; Function for minimum distance ; Function for maximum distance ; Driver Code
import java . io . * ; class GFG { static int pivotDis ( int x0 , int y0 , int x1 , int y1 ) { return ( int ) Math . sqrt ( ( x1 - x0 ) * ( x1 - x0 ) + ( y1 - y0 ) * ( y1 - y0 ) ) ; } static int minDis ( int D , int r1 , int r2 ) { return Math . max ( ( D - r1 - r2 ) , 0 ) ; } static int maxDis ( int D , int r1 , int r2 ) { return D + r1 + r2 ; } public static void main ( String [ ] args ) { int x0 = 0 , y0 = 0 , x1 = 8 , y1 = 0 , r1 = 4 , r2 = 5 ; int D = pivotDis ( x0 , y0 , x1 , y1 ) ; System . out . print ( " Distance ▁ while ▁ " + " repulsion ▁ = ▁ " + maxDis ( D , r1 , r2 ) ) ; System . out . print ( " Distance while " + " attraction ▁ = ▁ " + minDis ( D , r1 , r2 ) ) ; } }
Find the other end point of a line with given one end and mid | Java program to find the end point of a line ; CPP function to find the end point of a line ; find end point for x coordinates ; find end point for y coordinates ; Driven Program
class GFG { static void otherEndPoint ( int x1 , int y1 , int m1 , int m2 ) { float x2 = ( float ) ( 2 * m1 - x1 ) ; float y2 = ( float ) ( 2 * m2 - y1 ) ; System . out . println ( " x2 ▁ = ▁ " + x2 + " , ▁ " + " y2 ▁ = ▁ " + y2 ) ; } public static void main ( String args [ ] ) { int x1 = - 4 , y1 = - 1 , m1 = 3 , m2 = 5 ; otherEndPoint ( x1 , y1 , m1 , m2 ) ; } }
Coordinates of rectangle with given points lie inside | Program to find smallest rectangle to conquer all points ; function to print coordinate of smallest rectangle ; find Xmax and Xmin ; find Ymax and Ymin ; print all four coordinates ; Driver code
import java . util . Arrays ; import java . util . Collections ; class GFG { static void printRect ( Integer X [ ] , Integer Y [ ] , int n ) { int Xmax = Collections . max ( Arrays . asList ( X ) ) ; int Xmin = Collections . min ( Arrays . asList ( X ) ) ; int Ymax = Collections . max ( Arrays . asList ( Y ) ) ; int Ymin = Collections . min ( Arrays . asList ( Y ) ) ; System . out . println ( " { " + Xmin + " , ▁ " + Ymin + " } " ) ; System . out . println ( " { " + Xmin + " , ▁ " + Ymax + " } " ) ; System . out . println ( " { " + Xmax + " , ▁ " + Ymax + " } " ) ; System . out . println ( " { " + Xmax + " , ▁ " + Ymin + " } " ) ; } public static void main ( String [ ] args ) { Integer X [ ] = { 4 , 3 , 6 , 1 , - 1 , 12 } ; Integer Y [ ] = { 4 , 1 , 10 , 3 , 7 , - 1 } ; int n = X . length ; printRect ( X , Y , n ) ; } }
Check if a line passes through the origin | Java program to find if line passing through two coordinates also passes through origin or not ; Driver code
import java . io . * ; class GFG { static boolean checkOrigin ( int x1 , int y1 , int x2 , int y2 ) { return ( x1 * ( y2 - y1 ) == y1 * ( x2 - x1 ) ) ; } public static void main ( String [ ] args ) { if ( checkOrigin ( 1 , 28 , 2 , 56 ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Number of horizontal or vertical line segments to connect 3 points | Java program to find number of horizontal ( or vertical line segments needed to connect three points . ; Function to check if the third point forms a rectangle with other two points at corners ; Returns true if point k can be used as a joining point to connect using two line segments ; Check for the valid polyline with two segments ; Check whether the X - coordinates or Y - cocordinates are same . ; Iterate over all pairs to check for two line segments ; Otherwise answer is three . ; Driver code
import java . io . * ; class GFG { static boolean isBetween ( int a , int b , int c ) { return ( Math . min ( a , b ) <= c && c <= Math . max ( a , b ) ) ; } static boolean canJoin ( int x [ ] , int y [ ] , int i , int j , int k ) { return ( x [ k ] == x [ i ] x [ k ] == x [ j ] ) && isBetween ( y [ i ] , y [ j ] , y [ k ] ) || ( y [ k ] == y [ i ] y [ k ] == y [ j ] ) && isBetween ( x [ i ] , x [ j ] , x [ k ] ) ; } static int countLineSegments ( int x [ ] , int y [ ] ) { if ( ( x [ 0 ] == x [ 1 ] && x [ 1 ] == x [ 2 ] ) || ( y [ 0 ] == y [ 1 ] && y [ 1 ] == y [ 2 ] ) ) return 1 ; else if ( canJoin ( x , y , 0 , 1 , 2 ) || canJoin ( x , y , 0 , 2 , 1 ) || canJoin ( x , y , 1 , 2 , 0 ) ) return 2 ; else return 3 ; } public static void main ( String [ ] args ) { int x [ ] = new int [ 3 ] , y [ ] = new int [ 3 ] ; x [ 0 ] = - 1 ; y [ 0 ] = - 1 ; x [ 1 ] = - 1 ; y [ 1 ] = 3 ; x [ 2 ] = 4 ; y [ 2 ] = 3 ; System . out . println ( countLineSegments ( x , y ) ) ; } }
Pythagorean Quadruple | Java code to detect Pythagorean Quadruples . ; function for checking ; Driver function
import java . io . * ; import java . util . * ; class GFG { static Boolean pythagorean_quadruple ( int a , int b , int c , int d ) { int sum = a * a + b * b + c * c ; if ( d * d == sum ) return true ; else return false ; } public static void main ( String [ ] args ) { int a = 1 , b = 2 , c = 2 , d = 3 ; if ( pythagorean_quadruple ( a , b , c , d ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Program for Volume and Surface area of Frustum of Cone | Java program to calculate Volume and Surface area of frustum of cone ; Function to calculate Volume of frustum of cone ; Function to calculate Curved Surface area of frustum of cone ; Function to calculate Total Surface area of frustum of cone ; Driver function ; Printing value of volume and surface area
public class demo { static float pi = 3.14159f ; public static float volume ( float r , float R , float h ) { return ( float ) 1 / 3 * pi * h * ( r * r + R * R + r * R ) ; } public static float curved_surface_area ( float r , float R , float l ) { return pi * l * ( R + r ) ; } public static float total_surface_area ( float r , float R , float l , float h ) { return pi * l * ( R + r ) + pi * ( r * r + R * R ) ; } public static void main ( String args [ ] ) { float small_radius = 3 ; float big_radius = 8 ; float slant_height = 13 ; float height = 12 ; System . out . print ( " Volume ▁ Of ▁ Frustum ▁ of ▁ Cone ▁ : ▁ " ) ; System . out . println ( volume ( small_radius , big_radius , height ) ) ; System . out . print ( " Curved ▁ Surface ▁ Area ▁ Of " + " ▁ Frustum ▁ of ▁ Cone ▁ : ▁ " ) ; System . out . println ( curved_surface_area ( small_radius , big_radius , slant_height ) ) ; System . out . print ( " Total ▁ Surface ▁ Area ▁ Of " + " ▁ Frustum ▁ of ▁ Cone ▁ : ▁ " ) ; System . out . println ( total_surface_area ( small_radius , big_radius , slant_height , height ) ) ; } }
Program to find Perimeter / Circumference of Square and Rectangle | Java program to find Circumference of a square ; Driver code
import java . io . * ; class GFG { int Circumference ( int a ) { return 4 * a ; } public static void main ( String args [ ] ) { GFG obj = new GFG ( ) ; int a = 5 ; System . out . println ( " Circumference ▁ of ▁ " + " a ▁ square ▁ is ▁ " + obj . Circumference ( a ) ) ; } }
Maximum area of quadrilateral | Java program to find maximum are of a quadrilateral ; Calculating the semi - perimeter of the given quadrilateral ; Applying Brahmagupta 's formula to  get maximum area of quadrilateral ; Driver code
import java . io . * ; class GFG { static double maxArea ( double a , double b , double c , double d ) { double semiperimeter = ( a + b + c + d ) / 2 ; return Math . sqrt ( ( semiperimeter - a ) * ( semiperimeter - b ) * ( semiperimeter - c ) * ( semiperimeter - d ) ) ; } public static void main ( String [ ] args ) { double a = 1 , b = 2 , c = 1 , d = 2 ; System . out . println ( maxArea ( a , b , c , d ) ) ; } }
Direction of a Point from a Line Segment | Java Program to Determine Direction of Point from line segment ; structure for point in cartesian plane . ; constant integers for directions ; subtracting co - ordinates of point A from B and P , to make A as origin ; Determining cross Product ; return RIGHT if cross product is positive ; return LEFT if cross product is negative ; return ZERO if cross product is zero . ; Driver code ; A . y = 10 ; A ( - 30 , 10 ) ; B . y = - 15 ; B ( 29 , - 15 ) ; P . y = 28 ; P ( 15 , 28 )
class GFG { static class point { int x , y ; } ; static int RIGHT = 1 , LEFT = - 1 , ZERO = 0 ; static int directionOfPoint ( point A , point B , point P ) { B . x -= A . x ; B . y -= A . y ; P . x -= A . x ; P . y -= A . y ; int cross_product = B . x * P . y - B . y * P . x ; if ( cross_product > 0 ) return RIGHT ; if ( cross_product < 0 ) return LEFT ; return ZERO ; } public static void main ( String [ ] args ) { point A = new point ( ) , B = new point ( ) , P = new point ( ) ; A . x = - 30 ; B . x = 29 ; P . x = 15 ; int direction = directionOfPoint ( A , B , P ) ; if ( direction == 1 ) System . out . println ( " Right ▁ Direction " ) ; else if ( direction == - 1 ) System . out . println ( " Left ▁ Direction " ) ; else System . out . println ( " Point ▁ is ▁ on ▁ the ▁ Line " ) ; } }
Find minimum radius such that atleast k point lie inside the circle | Java program to find minimum radius such that atleast k point lie inside the circle ; Return minimum distance required so that aleast k point lie inside the circle . ; Finding distance between of each point from origin ; Sorting the distance ; Driven Program
import java . util . Arrays ; class GFG { static int minRadius ( int k , int [ ] x , int [ ] y , int n ) { int [ ] dis = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) dis [ i ] = x [ i ] * x [ i ] + y [ i ] * y [ i ] ; Arrays . sort ( dis ) ; return dis [ k - 1 ] ; } public static void main ( String [ ] args ) { int k = 3 ; int [ ] x = { 1 , - 1 , 1 } ; int [ ] y = { 1 , - 1 , - 1 } ; int n = x . length ; System . out . println ( minRadius ( k , x , y , n ) ) ; } }
Program for Area And Perimeter Of Rectangle | Java program to find area and perimeter of rectangle ; Utility function ; Driver Function
import java . io . * ; class Geometry { static int areaRectangle ( int a , int b ) { int area = a * b ; return area ; } static int perimeterRectangle ( int a , int b ) { int perimeter = 2 * ( a + b ) ; return perimeter ; } public static void main ( String [ ] args ) { int a = 5 ; int b = 6 ; System . out . println ( " Area ▁ = ▁ " + areaRectangle ( a , b ) ) ; System . out . println ( " Perimeter ▁ = ▁ " + perimeterRectangle ( a , b ) ) ; } }
Program for Area Of Square | Java program to find the area of the square ; Driver Code
import java . util . * ; class GFG { static int areaSquare ( int side ) { int area = side * side ; return area ; } public static void main ( String [ ] args ) { int side = 5 ; System . out . println ( areaSquare ( 4 ) ) ; } }
Minimum Perimeter of n blocks | JAVA Code to find minimum perimeter using n blocks ; if n is a perfect square ; Number of rows ; perimeter of the rectangular grid ; if there are blocks left ; Driver code
import java . util . * ; class GFG { public static long minPerimeter ( int n ) { int l = ( int ) Math . sqrt ( n ) ; int sq = l * l ; if ( sq == n ) return l * 4 ; else { long row = n / l ; long perimeter = 2 * ( l + row ) ; if ( n % l != 0 ) perimeter += 2 ; return perimeter ; } } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( minPerimeter ( n ) ) ; } }
Find if it 's possible to rotate the page by an angle or not. | java program to find if its possible to rotate page or not ; function to find if it 's possible  to rotate page or not ; Calculating distance b / w points ; If distance is not equal ; If the points are in same line ; Driver method ; Points a , b , and c
import java . util . Arrays ; class GFG { static void possibleOrNot ( long a1 , long a2 , long b1 , long b2 , long c1 , long c2 ) { long dis1 = ( long ) Math . pow ( b1 - a1 , 2 ) + ( long ) Math . pow ( b2 - a2 , 2 ) ; long dis2 = ( long ) Math . pow ( c1 - b1 , 2 ) + ( long ) Math . pow ( c2 - b2 , 2 ) ; if ( dis1 != dis2 ) System . out . print ( " No " ) ; else if ( b1 == ( ( a1 + c1 ) / 2.0 ) && b2 == ( ( a2 + c2 ) / 2.0 ) ) System . out . print ( " No " ) ; else System . out . print ( " Yes " ) ; } public static void main ( String [ ] args ) { long a1 = 1 , a2 = 0 , b1 = 2 , b2 = 0 , c1 = 3 , c2 = 0 ; possibleOrNot ( a1 , a2 , b1 , b2 , c1 , c2 ) ; } }
Check if two given circles touch or intersect each other | Java program to check if two circles touch each other or not . ; Driver code
import java . io . * ; class GFG { static int circle ( int x1 , int y1 , int x2 , int y2 , int r1 , int r2 ) { int distSq = ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ; int radSumSq = ( r1 + r2 ) * ( r1 + r2 ) ; if ( distSq == radSumSq ) return 1 ; else if ( distSq > radSumSq ) return - 1 ; else return 0 ; } public static void main ( String [ ] args ) { int x1 = - 10 , y1 = 8 ; int x2 = 14 , y2 = - 24 ; int r1 = 30 , r2 = 10 ; int t = circle ( x1 , y1 , x2 , y2 , r1 , r2 ) ; if ( t == 1 ) System . out . println ( " Circle ▁ touch ▁ to " + " ▁ each ▁ other . " ) ; else if ( t < 0 ) System . out . println ( " Circle ▁ not ▁ touch " + " ▁ to ▁ each ▁ other . " ) ; else System . out . println ( " Circle ▁ intersect " + " ▁ to ▁ each ▁ other . " ) ; } }
Count of obtuse angles in a circle with ' k ' equidistant points between 2 given points | Java program to count number of obtuse angles for given two points ; There are two arcs connecting a and b . Let us count points on both arcs . ; Both arcs have same number of points ; Points on smaller arc is answer ; Driver Program to test above function
class GFG { static int countObtuseAngles ( int a , int b , int k ) { int c1 = ( b - a ) - 1 ; int c2 = ( k - b ) + ( a - 1 ) ; if ( c1 == c2 ) return 0 ; return min ( c1 , c2 ) ; } public static void main ( String arg [ ] ) { int k = 6 , a = 1 , b = 3 ; System . out . print ( countObtuseAngles ( a , b , k ) ) ; } }