double x, y;
Circle(double x1,double y1, double radius)
void check(double x2, double y2)
System.out.println("the point lies inside circle with "+x+","+y+" as centre");
System.out.println("the point doesnt lie inside the circle with "+x+","+y+" as centre and "+radius+" as radius");
public static void main(String args) throws Exception
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter circle details");
System.out.print("Enter x co-ordinate:");
System.out.print("Enter y co-ordinate:");
System.out.println("The circle you have entered is having centre at ("+xx+","+yy+") and radius="+rr);
Circle c=new Circle(xx,yy,rr);
System.out.println("Enter the point you want to check");
Well as you guys see, this concept receives input of one circle with its center and the radius value and another point co-ordinates, which we have to compare and tell that the point lies inside the circle or not. For that we can use a very simple concept. First we will calculate the distance of the given point with the center of the circle which I have done by using formula d2=Math.sqrt((x-x2)*(x-x2)-(y-y2)*(y-y2)) . After this we have to compare it with the radius value. If it is less than the radius value, then it is inside the circle, otherwise it is not inside the circle.
Well that’s it for now guys. Hope you liked the concept. If you find some bugs or have queries then write in the comments section below or you can contact me through my profile. And kindly subscribe to our website, its totally free!!
Keep coding, Thank you.
Latest posts by Bikash Panda (see all)
- OSMC on Raspberry PI with Setup and Control using Android App - July 7, 2017
- DHT12 Interfacing with Raspberry Pi using Pi4J - June 19, 2017
- Send data using MQTT from Raspberry Pi with JAVA - June 12, 2017