Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A circle is a plane in space with points x and y and a radius r. Create a class

ID: 3689924 • Letter: A

Question

A circle is a plane in space with points x and y and a radius r. Create a class that stores a collection of circles. Add pseudocode for a class method for your class that takes x and y coordinates as parameters and returns the circles that contain that point (that is, those circles where the requested point is within their radius, think of comparators). This method can be pseudocode however, make sure to write an explicit java method signature (like an interface) that illustrates what this method takes as input and what it returns. What is the growth rate of this method, in big-O notation? What constitutes the input size for the big-O notation? Note: it doesn’t have to be a particularly good data structure or method - I’m just looking to see that you can describe it.

A circle is a plane in space with points x and y and a radius r. Create a class that stores a collection of circles. Add pseudocode for a class method for your class that takes x and y coordinates as parameters and returns the circles that contain that point (that is, those circles where the requested point is within their radius, think of comparators). This method can be pseudocode however, make sure to write an explicit java method signature (like an interface) that illustrates what this method takes as input and what it returns. What is the growth rate of this method, in big-O notation? What constitutes the input size for the big-O notation? Note: it doesn’t have to be a particularly good data structure or method - I’m just looking to see that you can describe it.
A circle is a plane in space with points x and y and a radius r. Create a class that stores a collection of circles. Add pseudocode for a class method for your class that takes x and y coordinates as parameters and returns the circles that contain that point (that is, those circles where the requested point is within their radius, think of comparators). This method can be pseudocode however, make sure to write an explicit java method signature (like an interface) that illustrates what this method takes as input and what it returns. What is the growth rate of this method, in big-O notation? What constitutes the input size for the big-O notation? Note: it doesn’t have to be a particularly good data structure or method - I’m just looking to see that you can describe it.
A circle is a plane in space with points x and y and a radius r. Create a class that stores a collection of circles. Add pseudocode for a class method for your class that takes x and y coordinates as parameters and returns the circles that contain that point (that is, those circles where the requested point is within their radius, think of comparators). This method can be pseudocode however, make sure to write an explicit java method signature (like an interface) that illustrates what this method takes as input and what it returns. What is the growth rate of this method, in big-O notation? What constitutes the input size for the big-O notation? Note: it doesn’t have to be a particularly good data structure or method - I’m just looking to see that you can describe it.

Explanation / Answer


/**
* The java program that illustatates the Circle
* that tests the points whether they are inside
* the circle or not. Print the point and number of
* points lies inside the circle
* */
//Circle.java
public class Circle {
  
   private double x;
   private double y;
   private double r;
  
   //Circle constructo
   public Circle(double x,int y,double r) {
       this.x=x;
       this.y=y;
       this.r=r;
   }
  
   public double getRadius()
   {
       return r;
   }
  
   //Returns the distance between center of circle and point
   public double getDistance(double pX,double pY)
   {
       return Math.sqrt(Math.pow((x-pX),2.0)+Math.pow((y-pY),2.0));
   }
  
   //Returns the string description of circle
   @Override
   public String toString() {      
       return "("+x+","+y+") of radius "+r;
   }
  
}


------------------------------------------------------------------------------------------------------------


//InsideCircle.java
public class InsideCircle {
  
   public static void main(String[] args)
   {      
       //Create a circle of radius ,10
       Circle circle=new Circle(1,1,10);  
       //set pointsCount=0;
       int pointsCount=0;  
      
       //Generate 10 random points within a range of 1 to 20
       //for pX and pY
       for (int i = 0; i < 10; i++)
       {
           int pX=(int)(Math.random()*20+1);
           int pY=(int)(Math.random()*20+1);
          
           //Call inCircle that takes circle ad pX,pY
           //returns true if the point (pX,pY) in circle
           if(inCircle(circle, pX, pY))
           {
               System.out.print("("+pX+","+pY+")");
               System.out.println(" lies inside circle "+circle.toString());
               pointsCount++;
           }
       }
      
       System.out.println("Number of points lies inside circle : "+pointsCount);      
   }
  
   /**The method inCircle that takes circle objct and px and py
   * and return true if the point lies inside othewise returns false*/
   public static boolean inCircle(Circle c,double pX,double pY)
   {      
       //Call getDistance on point
       //check if the distance is less than the radius
       if(c.getDistance(pX, pY)<c.getRadius())      
           //return true
           return true;
       else
           //otherwise return false
           return false;      
   }
}


---------------------------------------------------------------------------------------------

Sample output:

(9,6) lies inside circle (1.0,1.0) of radius 10.0
(4,10) lies inside circle (1.0,1.0) of radius 10.0
(1,5) lies inside circle (1.0,1.0) of radius 10.0
(6,8) lies inside circle (1.0,1.0) of radius 10.0
Number of points lies inside circle : 4

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote