Created
August 29, 2018 06:51
-
-
Save rr-codes/38aa978a18bb89d575855288f54c130c to your computer and use it in GitHub Desktop.
This file contains 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) 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