Check if given point lies in range of any of the given towers | Java program to implement the above approach ; Function to check if the point ( X , Y ) exists in the towers network - range or not ; Traverse the array arr [ ] ; Stores distance of the point ( X , Y ) from i - th tower ; If dist lies within the range of the i - th tower ; If the point ( X , Y ) does not lie in the range of any of the towers ; Driver Code ; If point ( X , Y ) lies in the range of any of the towers ; Otherwise
import java . util . * ; class GFG { static boolean checkPointRange ( int arr [ ] [ ] , int X , int Y , int N ) { for ( int i = 0 ; i < N ; i ++ ) { double dist = Math . sqrt ( ( arr [ i ] [ 0 ] - X ) * ( arr [ i ] [ 0 ] - X ) + ( arr [ i ] [ 1 ] - Y ) * ( arr [ i ] [ 1 ] - Y ) ) ; if ( dist <= arr [ i ] [ 2 ] ) { return true ; } } return false ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 1 , 1 , 3 } , { 10 , 10 , 3 } , { 15 , 15 , 15 } } ; int X = 5 , Y = 5 ; int N = arr . length ; if ( checkPointRange ( arr , X , Y , N ) ) { System . out . print ( " True " ) ; } else { System . out . print ( " False " ) ; } } }