-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistance.java
More file actions
23 lines (18 loc) · 861 Bytes
/
Distance.java
File metadata and controls
23 lines (18 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Hamic.BasicJava.week1;
import java.util.Scanner;
public class Distance {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
System.out.print("Enter the coordinates of the point A (x, y, z): ");
double x1 = scanner.nextDouble();
double y1 = scanner.nextDouble();
double z1 = scanner.nextDouble();
System.out.print("Enter the coordinates of the point B (a, b, c): ");
double x2 = scanner.nextDouble();
double y2 = scanner.nextDouble();
double z2 = scanner.nextDouble();
double distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2));
System.out.println("The distance between two points is: " + distance);
}
}
}