Skip to content

Instantly share code, notes, and snippets.

@rr-codes
Created August 29, 2018 06:51
Show Gist options
  • Save rr-codes/38aa978a18bb89d575855288f54c130c to your computer and use it in GitHub Desktop.
Save rr-codes/38aa978a18bb89d575855288f54c130c to your computer and use it in GitHub Desktop.
import java.util.*;
public class Distance {
public static void main(String[] args) throws Exception {
int sum = 0;
int[][] arr = new int[2][10];
Scanner point = new Scanner(System.in);
System.out.print("Enter point: ");
for (int j = 0; point.hasNextInt(); j++) {
arr[0][j] = point.nextInt();
}
point.close();
Scanner point2 = new Scanner(System.in);
System.out.print("Enter point: ");
for (int j = 0; point2.hasNextInt(); j++) {
arr[1][j] = point2.nextInt();
}
point2.close();
for (int i = 0; i < arr[0].length; i++) {
int diff = arr[1][i] - arr[0][i];
sum += diff*diff;
}
System.out.println(Math.sqrt(sum));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment