Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program will keep track of the total distance for a trip through several cit

ID: 3687855 • Letter: T

Question

The program will keep track of the total distance for a trip through several cities.Assume that we have cities 0,1, 2, and 3. We will enter the number for each city on the each city on the route as the program asks for each city from start to finish. Assume that the distances are as follows: Notice that only the distances for the bottom triangle of the table are shown The assumption is that the distance between 2 cities does not depend on which direction you are going. So, the program should use a ragged array, as described on page 290 of the textbook. The program should perform as follows. middot The program will ask for the staiting point of the trip It will accept a number as the start of this step in the travel. middot It will begin a loop which will: smallCircle ask for die next stop in die trip smallCircle store the user's reply as the number for the stopping point smallCircle copy die values of the starting and ending points into the values of variables r and c such that the value of r is greater than or equal to the value of c smallCircle use the values of r and c (for row and column values) to find the next distance traveled and add it to the total distance smallCircle copy the value of the stopping point into the variable for the starting point smallCircle ask if there is another city to visit smallCircle get the reply from the user and if it is 'Y' or 'y' go back to the top of the loop middot display the value of the displace traveled

Explanation / Answer

Hi below i have wriiten a sample Java code similar to this program for your reference and hope this helps , thanks :)

import java.io.*;