Check whether given circle resides in boundary maintained by two other circles | Java program to check whether circle with given co - ordinates reside within the boundary of outer circle and inner circle ; function to check if given circle fit in boundary or not ; Distance from the center ; Checking the corners of circle ; driver program ; Radius of outer circle and inner circle respectively ; Co - ordinates and radius of the circle to be checked
import java . util . * ; class GFG { static void fitOrNotFit ( int R , int r , int x , int y , int rad ) { double val = Math . sqrt ( Math . pow ( x , 2 ) + Math . pow ( y , 2 ) ) ; if ( val + rad <= R && val - rad >= R - r ) System . out . println ( " Fits " ) ; else System . out . println ( " Doesn ' t ▁ Fit " ) ; } public static void main ( String [ ] args ) { int R = 8 , r = 4 ; int x = 5 , y = 3 , rad = 3 ; fitOrNotFit ( R , r , x , y , rad ) ; } }