Question: Listing 8.3 gives a program that finds two points in a two-dimensional space nearest to each other. Revise the program so that it finds two
Listing 8.3 gives a program that finds two points in a two-dimensional space nearest to each other. Revise the program so that it finds two points in a three-dimensional space nearest to each other. Use a two-dimensional array to represent the points. Test the program using the following points:double[][] points = {{-1, 0, 3}, {-1, -1, -1}, {4, 1, 1}, {2, 0.5, 9}, {3.5, 2, -1}, {3, 1.5, 3}, {-1.5, 4, 2}, {5.5, 4, -0.5}};The formula for computing the distance between two points (x1, y1, z1) and (x2, y2, z2) is![]()
Listing
![]()
![]()
![]()
V( x) + (92 y) + (z2 z1). 1 import java.util.Scanner; 2 3 public class FindNearestPoints { public static void main(String[] args) { Scanner input = new Scanner(System.in); 4 15 System.out.print("Enter the number of points: "); int numberofPoints = input.nextInt(); 19 // Create an array to store points
Step by Step Solution
3.44 Rating (170 Votes )
There are 3 Steps involved in it
Java program for Points nearest to each other Comp... View full answer
Get step-by-step solutions from verified subject matter experts
