Question: You are first to implement a class named Point2D to store a coordinate pair (xy) and to compute Euclidean /L2 distances' between points in two-dimensional
You are first to implement a class named Point2D to store a coordinate pair (xy) and to compute Euclidean /L2 distances' between points in two-dimensional space. The class has one constructor to initialize the coordinates and a no-arg constructor (which you should make use the first) that sets the point to the origin (o,o). It has getter methods for both coordinates, as well as a tostring method to return the familiar (x.y) format (both with three decimal pl method to calculate the Euclidean distance between two points, and a member method (which must use the static method) to calculate from one instance to a supplied other. laces of precision). Finally, there's a static You must also complete a program that takes a single point via command-line arguments and computes the distance from the origin. Much of the main method has been written for you - you must validate command-line arguments and then construct a Point2D instance according to the supplied values. The following represent example runs... java edu.wit.cs.comp1050.PA3c Please supply 2 numbers (x y). java edu.wit.cs.comp1050.PA3c 0 1 Point 1: (0.000, 0.000) Point 2: (0.000, 1.00) Static method distance: 1.000 Distance from P1: 1.00e Distance from P2: 1.00e java edu.wit.cs.comp1050.PA3c 10 30.5 Point 1: (e.000, .00) Point 2: (10.000, 30.500) Static method distance: 32.098 Distance from P1: 32.098 Distance from P2: 32.098
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
