Friday, December 23, 2011

Program in java for to find coordinates of a circle


import java.util.*;
public class Ch2Q3
{    public static void main(String[] args)
     {double y, x1, y1, rad;
      Scanner kbd = new Scanner(System.in);
      System.out.print("Enter co-ordinates of the centre: ");
      double x = kbd.nextDouble();
      y = kbd.nextDouble();
      System.out.print("Enter radius of the circle: ");
      rad = kbd.nextDouble();
      System.out.print("Enter co-ordinates of the point: ");
      x1 = kbd.nextDouble();
      y1 = kbd.nextDouble();
      double dist = Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
      if(dist < rad)
      System.out.println("Point is inside the circle");
      else if(dist == rad)
              System.out.println("Point is on the circle");
           else System.out.println("Point is outside the circle");
     }
}

No comments:

Post a Comment