Question: Complete the following code segment such that your implementation of class Point supports the operations used in the main method. The methods that are needed

Complete the following code segment such that your implementation of class Point supports the operations used in the main method. The methods that are needed in the Point class are listed in the main method. Sample run Input:

3 4 5 4 1 1 -1 -1 0 0 0 -1 

Output:

3.605551275463989 6.4031242374328485 5.0 5.830951894845301 2

// TEST

import java.util.Scanner; import geometric.Point;

public class Test { public static void main(String[] args) { Scanner stdin = new Scanner(System.in);

double x = stdin.nextDouble(); double y = stdin.nextDouble();

// declare origin and initialize it with x and y // your code starts here

// your code ends here

double threshold = stdin.nextDouble();

Point[] pts = new Point[stdin.nextInt()];

for (int i = 0; i < pts.length; i++) { // call a constructor that initialize the x and y pts[i] = new Point(stdin.nextDouble(), stdin.nextDouble()); // distance method compute the distance from origin to another point System.out.println(origin.distance(pts[i])); }

// the within method in the Point class will count the number of // points in pts whose distance from origin is smaller than the // threshold System.out.println(origin.within(pts, threshold));

} }

// POINT

package geometric;

// your code starts here

// your code ends here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!