Last active
December 26, 2015 05:59
-
-
Save joeyv/7104734 to your computer and use it in GitHub Desktop.
Simple program to calculate the distance of two coordinates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| public class Distance | |
| { | |
| public static void main(String[] args) | |
| { | |
| int x1, y1; | |
| int x2, y2; | |
| int inside, distance; | |
| Scanner scan = new Scanner(System.in); | |
| x1 = scan.nextInt(); | |
| y1 = scan.nextInt(); | |
| x2 = scan.nextInt(); | |
| y2 = scan.nextInt(); | |
| //equation inside of the square root | |
| inside = (int)Math.pow((x2-x1), 2) + (int)Math.pow((y2-y1), 2); | |
| //sqaure root of the inside | |
| distance = (int)Math.sqrt(inside); | |
| System.out.println (distance); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment