Is there a way to use this code without using Point2D? Thank you...

Question

# Is there a way to use this code without using Point2D? Thank you...

Is there a way to use this code without using Point2D? Thank you

Assignment: https://ds.cs.rutgers.edu/assignment-infinitywar/

Sample run:

6
0 0.5
1 0.3
2 0.2
3 0.1
4 0.9
5 0.7
0 1 4 0 0 0
1 0 4 2 7 0
4 4 0 3 5 0
0 2 3 0 4 6
0 7 5 4 0 7
0 0 0 6 7 0

https://codeshare.io/786WlD

``````public class LocateTitan {

public static void main (String[] args) {

if ( args.length < 2 ) {

StdOut.println("Execute: java  <INput file> <OUTput file>");

return;

}

In input = new In(args[0]);

Out output = new Out(args[1]);

output.println(numOfLines);

for (int i = 0; i < numOfLines; i++) {

output.println(numOfPoints);

Point2D[] points = new Point2D[numOfPoints];

for (int j = 0; j < numOfPoints; j++) {

points[j] = new Point2D(x, y);

}

Point2D titan = null;

double minDist = Double.MAX_VALUE;

for (int j = 0; j < numOfPoints; j++) {

Point2D curr = points[j];

double currDist = curr.distanceSquaredTo(new Point2D(0, 0));

if (currDist < minDist) {

minDist = currDist;

titan = curr;

}

}

output.println(titan.x() + " " + titan.y());

}

output.close();

}

}``````

Solved by verified expert

sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem i

sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis

10,000 step-by-step explanations

``sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor``