diff options
| author | mokha <mokha@cisco.com> | 2019-05-14 21:47:16 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-14 21:47:16 -0600 |
| commit | 2ecd84e4026c9438405ca7dec61158291214cedb (patch) | |
| tree | 79b3d6fc51fb7b8f7d51045a173620fb6b714270 /src/Q3/CartesianCoordinateSystem.java | |
| parent | e6aeae0240b71b1137184005c27f8528feeb1580 (diff) | |
add cli interface for Q3
Diffstat (limited to 'src/Q3/CartesianCoordinateSystem.java')
| -rw-r--r-- | src/Q3/CartesianCoordinateSystem.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Q3/CartesianCoordinateSystem.java b/src/Q3/CartesianCoordinateSystem.java index c41dbeb..abd7341 100644 --- a/src/Q3/CartesianCoordinateSystem.java +++ b/src/Q3/CartesianCoordinateSystem.java @@ -9,6 +9,8 @@ */ package Q3; +import java.util.Scanner; + public class CartesianCoordinateSystem { /** * Calculate the distance between two points. @@ -22,4 +24,23 @@ public class CartesianCoordinateSystem { public double calculateDistance(double x1, double y1, double x2, double y2) { return Math.round(Math.pow(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2), 0.5) * 100) / 100.0; } + + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + + System.out.print("Please enter X1: "); + double x1 = in.nextDouble(); + + System.out.print("Please enter Y1 contributions: "); + double y1 = in.nextDouble(); + + System.out.print("Please enter X2 contributions: "); + double x2 = in.nextDouble(); + + System.out.print("Please enter Y2 contributions: "); + double y2 = in.nextDouble(); + + CartesianCoordinateSystem cartesian = new CartesianCoordinateSystem(); + System.out.println("The distance is " + cartesian.calculateDistance(x1, y1, x2, y2)); + } } |
