diff options
| author | mo <mo.khan@gmail.com> | 2019-05-25 15:27:51 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2019-05-25 15:27:51 -0600 |
| commit | 856c35dbc7080922bfff7c10a7a844a9d0a1cd65 (patch) | |
| tree | 739b413bc2a29adc35229ef2fd9b30581601a206 /src/Q3/CartesianCoordinateSystem.java | |
| parent | 46f68298527e0c59b9f34003b687259477093fde (diff) | |
start assignment 2
Diffstat (limited to 'src/Q3/CartesianCoordinateSystem.java')
| -rw-r--r-- | src/Q3/CartesianCoordinateSystem.java | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/Q3/CartesianCoordinateSystem.java b/src/Q3/CartesianCoordinateSystem.java deleted file mode 100644 index abd7341..0000000 --- a/src/Q3/CartesianCoordinateSystem.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Assignment 1, COMP268 Class: CartesianCoordinateSystem.java - * - * @description Represents an object that can calculate the distance between two points on a - * cartesian plain - * @author: mo khan Student ID: 3431709 - * @date May 7, 2019 - * @version 1.0 - */ -package Q3; - -import java.util.Scanner; - -public class CartesianCoordinateSystem { - /** - * Calculate the distance between two points. - * - * @param x1 x coordinate for the first point. - * @param y1 y coordinate for the first point. - * @param x2 x coordinate for the second point. - * @param y2 y coordinate for the second point. - * @return the distance between the two points - */ - 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)); - } -} |
