circle

circle

Program to test whether a given point lies inside a circle or not?

View Answers

December 23, 2010 at 12:31 PM

Hi Friend,

Try the following code:

import java.util.*;
public class CheckPoint{
    public static void main(String[]args){
        Scanner input=new Scanner(System.in);
        System.out.print("Enter the radius of the circle : ");
            double r = input.nextDouble();
            System.out.println();
            System.out.print("Enter x coordinate of the centre of circle : ");
            double x1 = input.nextDouble();
            System.out.print("Enter y coordinate of the centre of circle : ");
            double y1 = input.nextDouble();
            System.out.println();
            System.out.print("Enter x coordinate of the point: ");
            double x2 = input.nextDouble(); 
            System.out.print("Enter y coordinate of the point: ");
            double y2 = input.nextDouble();
            double b=2;
            double x=Math.pow(x2-x1,b);
            double y=Math.pow(y2-y1,b);
             System.out.println();
            double check =Math.sqrt(x+y);
            if (check < r){
                System.out.println("Point lies inside the Circle");
            }
            else if (check == r){
                System.out.println("Point lies on the Circle");
            }
            else{
                System.out.println("Point lies outside the Circle");
            }
}
}

Thanks









Related Tutorials/Questions & Answers:
circle
circle  Program to test whether a given point lies inside a circle... of the circle : "); double r = input.nextDouble... of circle : "); double x1 = input.nextDouble(); System.out.print
Creating circle inside a circle
Creating circle inside a circle  hi can any one give code for following output by awt/swing creating circle inside a circle ,outside cirlce and intersect a circle
Advertisements
Java Circle to Circle collision detection
Java Circle to Circle collision detection  Java Circle to Circle collision detection
ModuleNotFoundError: No module named 'circle'
ModuleNotFoundError: No module named 'circle'  Hi, My Python... 'circle' How to remove the ModuleNotFoundError: No module named 'circle'... to install padas library. You can install circle python with following command
ModuleNotFoundError: No module named 'circle'
ModuleNotFoundError: No module named 'circle'  Hi, My Python... 'circle' How to remove the ModuleNotFoundError: No module named 'circle'... to install padas library. You can install circle python with following command
ModuleNotFoundError: No module named 'circle'
ModuleNotFoundError: No module named 'circle'  Hi, My Python... 'circle' How to remove the ModuleNotFoundError: No module named 'circle'... to install padas library. You can install circle python with following command
Circle question - Java Beginners
Circle question  Hey You helped me with one this question already... that uses Circle class you created in the previous assignment. ? The program includes a static method createCircle() that o reads a radius of a circle from
area of a circle - Java Beginners
area of a circle  Write a class circle which consists of functions getdata() and area(), and also write a main program to create a circle object and to find the area by calling the function area () in circle class and display
BlueJ (area of circle)
BlueJ (area of circle)  How does one write a program to calculate the area of a circle in BlueJ? Note that the user will have to provide the radius.   A simple program to calculate the area of a circle. radius provided
How do I handle the reaction of a circle and a semi-circle colliding in java?
How do I handle the reaction of a circle and a semi-circle colliding in java?  How do I handle the reaction of a circle and a semi-circle colliding in java
How to draw a circle bucket, draw a circle bucket, circle bucket
How to draw a circle bucket       This example has a simple way to learn easily to make a circle shape.... ADS_TO_REPLACE_2 Draw Circle: Now draw a circle inside the big circle with any
By using Applet display a circle in a rectangle
By using Applet display a circle in a rectangle  Write a java applet to display a circle in a rectangle
setting RGB for a circle
setting RGB for a circle  how can i change the color of the circle(not through filling it) and i want to use RGB (not regular colors such as black or red..) i should include RGB numbers (for example 240, 150, 19) but i am
ModuleNotFoundError: No module named 'circle-asset'
ModuleNotFoundError: No module named 'circle-asset'  Hi, My Python... 'circle-asset' How to remove the ModuleNotFoundError: No module named 'circle-asset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'circle-asset'
ModuleNotFoundError: No module named 'circle-asset'  Hi, My Python... 'circle-asset' How to remove the ModuleNotFoundError: No module named 'circle-asset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Circle-Beacon'
ModuleNotFoundError: No module named 'Circle-Beacon'  Hi, My... 'Circle-Beacon' How to remove the ModuleNotFoundError: No module named 'Circle-Beacon' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Circle-Beacon'
ModuleNotFoundError: No module named 'Circle-Beacon'  Hi, My... 'Circle-Beacon' How to remove the ModuleNotFoundError: No module named 'Circle-Beacon' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Circle-Map'
ModuleNotFoundError: No module named 'Circle-Map'  Hi, My Python... 'Circle-Map' How to remove the ModuleNotFoundError: No module named 'Circle-Map' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'Circle-Map'
ModuleNotFoundError: No module named 'Circle-Map'  Hi, My Python... 'Circle-Map' How to remove the ModuleNotFoundError: No module named 'Circle-Map' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'Circle-Map'
ModuleNotFoundError: No module named 'Circle-Map'  Hi, My Python... 'Circle-Map' How to remove the ModuleNotFoundError: No module named 'Circle-Map' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'Circle-Tickler'
ModuleNotFoundError: No module named 'Circle-Tickler'  Hi, My... named 'Circle-Tickler' How to remove the ModuleNotFoundError: No module named 'Circle-Tickler' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'logi-circle'
ModuleNotFoundError: No module named 'logi-circle'  Hi, My Python... 'logi-circle' How to remove the ModuleNotFoundError: No module named 'logi-circle' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'my_Circle'
ModuleNotFoundError: No module named 'my_Circle'  Hi, My Python..._Circle' How to remove the ModuleNotFoundError: No module named 'my_Circle' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'circle-asset'
ModuleNotFoundError: No module named 'circle-asset'  Hi, My Python... 'circle-asset' How to remove the ModuleNotFoundError: No module named 'circle-asset' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Circle-Beacon'
ModuleNotFoundError: No module named 'Circle-Beacon'  Hi, My... 'Circle-Beacon' How to remove the ModuleNotFoundError: No module named 'Circle-Beacon' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'circle-fit'
ModuleNotFoundError: No module named 'circle-fit'  Hi, My Python... 'circle-fit' How to remove the ModuleNotFoundError: No module named 'circle-fit' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'Circle-Map'
ModuleNotFoundError: No module named 'Circle-Map'  Hi, My Python... 'Circle-Map' How to remove the ModuleNotFoundError: No module named 'Circle-Map' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'Circle-Tickler'
ModuleNotFoundError: No module named 'Circle-Tickler'  Hi, My... named 'Circle-Tickler' How to remove the ModuleNotFoundError: No module named 'Circle-Tickler' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangoldp-circle'
ModuleNotFoundError: No module named 'djangoldp-circle'  Hi, My... named 'djangoldp-circle' How to remove the ModuleNotFoundError: No module named 'djangoldp-circle' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'git-circle'
ModuleNotFoundError: No module named 'git-circle'  Hi, My Python... 'git-circle' How to remove the ModuleNotFoundError: No module named 'git-circle' error? Thanks   Hi, In your python environment you
How to design a circle logo, design a circle logo, a circle logo
How to design a circle logo     ... will learn here a simple circle logo, I have not used tough steps so it is easy... a Shape: Select a "Circle thin frame" by the Custom shape tool
Java GUI code- creating a circle
that prompts the user to enter the center and a point on the circle, which is (x,y)(x2,y2). The program should then output the circle's radius, circumference..., 100); setResizable(false); setTitle("Circle GUI
ModuleNotFoundError: No module named 'tap-circle-ci'
ModuleNotFoundError: No module named 'tap-circle-ci'  Hi, My... 'tap-circle-ci' How to remove the ModuleNotFoundError: No module named 'tap-circle-ci' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'great-circle-calculator'
ModuleNotFoundError: No module named 'great-circle-calculator'  Hi...: No module named 'great-circle-calculator' How to remove the ModuleNotFoundError: No module named 'great-circle-calculator' error? Thanks   
Java gui program for drawing rectangle and circle
gui program for drawing rectangle and circle? there shoud be circle.... and the program must also show message dialog "this is a red circle" when click circle button and red button. and same goes to "this is a red rectangle
How to Create Circle In Java
How to Create Circle In Java     ..., you will learn how to create Circle Diagram. The java circle is the most... the program define a class name CircleDraw for the circle component. 
Method which returns area of circle - Java Beginners
Java code you can return the area of a circle and give the radius... InputStreamReader(System.in)); System.out.print("Enter Radius of Circle... of Circle : "+area); double perimeter = a.perimeterOfCircle(r
How to calculate area of Circle
How to Calculate Area of Circle   ... of calculating  the area of circle. In this program you will be taught each and every... the area of circle. After that it return the area of circle, return the doubles type
Write a program to calculate area and perimeter of a circle
Write a program to calculate area and perimeter of a circle... and perimeter of a circle. First of all name a class as "CircleArea"... of the circle. Now use try exception to handle errors and other exceptional events
Flex Circle drawing example
Flex circle drawing example   ... and the button operator. The circle is not a default feature, the instructions for drawing a circle is defined inside the Sprite class of flash.display
ModuleNotFoundError: No module named 'test-pypi-version-circle-ci'
ModuleNotFoundError: No module named 'test-pypi-version-circle-ci'  ...: No module named 'test-pypi-version-circle-ci' How to remove the ModuleNotFoundError: No module named 'test-pypi-version-circle-ci' error? Thanks
ModuleNotFoundError: No module named 'test-pypi-version-circle-ci'
ModuleNotFoundError: No module named 'test-pypi-version-circle-ci'  ...: No module named 'test-pypi-version-circle-ci' How to remove the ModuleNotFoundError: No module named 'test-pypi-version-circle-ci' error? Thanks
how can i draw line between two panel contaning circle and line between their center?
how can i draw line between two panel contaning circle and line between their center?   how can i draw line between two panel contaning circle and line between their center
PHP GD circle
Draw An Arc in Graphics
Draw An Arc in Graphics       In this section, you will learn how to draw an arc in Graphics. An arc of a circle is a segment of the circumference of the circle. To draw an arc
J2ME Canvas Example
to draw the circle and rotate the circle continuously. The GameCanvas class has
How to design a text button.
How to design a text button.       With this tutorial you will be able to learn a design of the text button, mostly we use simple buttons of circle and rectangle shape
Java method final parameter
. In the example the radius parameter for calculating the area of circle have been...;of Circle= "+area); } public static void main(String
JavaFX 3D Effect Example
(like Creating Sphere with Circle and 3D text by blurring Text in background..._TO_REPLACE_19 Circle { centerX: bind val, centerY: 40 radius
PHP FORM Part-7
that moves into circle like a tier of bicycle. In programming, it?s similar to the bicycle tier. Apart from a programming loop, it will move into a circle till... words, we need to tell the PHP how it moves in the circle and how many rounds

Ads