Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Supriya Kurian
circle
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


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


Advertisement
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
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 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... style: Go to Layer menu > Layer style > Bevel and emboss. Draw Circle
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
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
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
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 "Circle thin frame" by the Custom shape tool (U key) with any
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
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... a class name CircleDraw for the circle component.  There is created two
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
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
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
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
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
Example - CirclePanel.java
Java NotesExample - CirclePanel.java Problem: The Java Graphics class draws a circle with drawOval(), whose parameters are not entirely intuitive... and height. The standard way of of thinking about a circle is the center point
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
JavaFX 3D Effect Example
(like Creating Sphere with Circle and 3D text by blurring Text in background... }, Circle { centerX: bind val, centerY: 40
Java method final parameter
. In the example the radius parameter for calculating the area of circle have been...*radius*radius; System.out.println("Area of Circle= "+area
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... in the circle and how many rounds it will take it. $sum++ Let's time to come out
Creating Canvas Form Example
and result will display on a Canvas circle. The Following methods are used
About Palika Bazaar Delhi
Circle. This is the main road that goes around the inside part of the centre. The specific part of the Inner Circle that the Palika Bazaar is located in is around the southwestern part of the circle. Radial Road 1 is located
circlr
circlr  how to write the circle code in html
need to solve the below question - Java Beginners
need to solve the below question  I need to write an application that uses the circle class.it must read a radius of a circle from the user .create a circle object and return the object
applet Question
applet Question  Write a java applet to display a circle in a rectangle
applet question
applet question  Write a java applet to display a rectangle inside a circle
applet question
applet question  Write a java applet to display atriangle inside a circle
color change
color change  how to change the color in circle using scrollbar
Java help - Java Beginners
Java help  I need to write an application that uses the circle class. It must read a radius of a circle from the user creates a circle object, and return the object. The program creates a circle object by using the above method
more circles - Java Beginners
more circles  Write an application that uses Circle class you created... createCircle() that o reads a radius of a circle from the user o creates a circle object, and o returns the object. ? The program creates a circle object by using
circles - Java Beginners
circles  Write Circle class. ? The class has one instance variable for diameter. ? The class has methods o Circle() // sets a default radius 5 o Circle(double radius) // sets radius // into the instance variable o
even more circles - Java Beginners
even more circles  Write an application that compares two circle objects. ? You need to include a new method equals(Circle c) in Circle class... ? The program then creates two circle objects ? and compares them by using equals
Java Program
400x400 pixels. Then when the user clicks at the window, a circle of size 20 pixels will be created. The circle will move linearly in a random direction with a speed of 5 pixels per second. When the circle collides with anything, say
Java Program
400x400 pixels. Then when the user clicks at the window, a circle of size 20 pixels will be created. The circle will move linearly in a random direction with a speed of 5 pixels per second. When the circle collides with anything, say
MEANING OF THe CODE IN BOLD LETTERS
MEANING OF THe CODE IN BOLD LETTERS  public static void main(sting args[]) { shape s[] = {new circle(),new rectangle()}; } //HERE SHAPE RECTANGLE AND CIRCLE ARE THREE CLASSES WHICH ARE DEFINED EARLIER IN THE PROGRAM
menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
java
java  Define a class named Circle with the following properties: ... the radius and the colour of the Circle object respectively. Set the default...? A default constructor. ? A constructor that creates Circle objects with the given
help please?
help please?  Define a class named Circle with the following... specify the radius and the colour of the Circle object respectively. Set...? A default constructor. ? A constructor that creates Circle objects
help please?
help please?  Define a class named Circle with the following... data fields specify the radius and the colour of the Circle object respectively... the value of pi. ? A default constructor. ? A constructor that creates Circle
help please?
help please?  Define a class named Circle with the following... data fields specify the radius and the colour of the Circle object respectively.... A default constructor. A constructor that creates Circle objects
help please?
help please?  Define a class named Circle with the following... data fields specify the radius and the colour of the Circle object respectively.... A default constructor. A constructor that creates Circle objects with the given
 

 

 

DMCA.com