Question: create a Word document that contains the pseudocode, flowchart, and test plan for this java program. NB: The Flowchart must be the actual diagram, not
create a Word document that contains the pseudocode, flowchart, and test plan for this java program. NB: The Flowchart must be the actual diagram, not a sketch.
import java.util.Scanner;
public class Exercise
public static void mainString args
Scanner input new ScannerSystemin;
System.out.printEnter the number of cities: ;
int numberOfCities input.nextInt;
System.out.printEnter the coordinates of the cities: ;
double cities new doublenumberOfCities;
for int i ; i cities.length; i
citiesi input.nextDouble;
citiesi input.nextDouble;
Find the central city and the total distance
from the central city to all other cities
double minTotal totalDistancecities;
int minIndex ;
for int i ; i cities.length; i
double total totalDistancecities i;
if minTotal total
minTotal total;
minIndex i;
System.out.printlnThe central city is at
citiesminIndex citiesminIndex;
System.out.printlnThe total distance to all other cities is
minTotal;
public static double totalDistancedouble cities, int i
double total ;
for int j ; j cities.length; j
total distancecitiesi citiesj;
return total;
public static double distancedouble c double c
return Math.sqrtc cc c
c cc c;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
