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

I need help on my java project. Overview In this project you will use Dijkstra\'

ID: 3560214 • Letter: I

Question

I need help on my java project.

Overview

In this project you will use Dijkstra's algorithm to find route information between two airports

    chosen by the user. The user will be shown a route that results in the lowest price.

Details: Write a command-line program (no GUI) that lets the user choose two airports and finds the route

    that has the least price.

Your program should read the airports.txt file that is posted, or any file having the same format.

    It should then prompt the user to enter two airports.

Dijkstra's algorithm should be run to find the cheapest route. The price, number of connections,

    and actual route should be shown.

    The user should be able to continue checking routes until no more routes are requested.

You are expected to write Dijkstra's algorithm yourself following the pseudocode found in both the

    slides and in the textbook. You can use the Vertex class and printPath found in the textbook.

    You may not use code for Dijkstra's algorithm found from other sources.

Your output should match the sample output below:

Sample output:

Enter departure airport: DFW

Enter arrival airport:    SFO

   By price:

      Price:       1100

      Connections: 1

      Route:       DFW -> LAX -> SFO

      Check another route (Y/N)?

Format required airports.txt :


ATL BOS 250 DFW 250 MOB 59

AUS DFW 59 HOU 59 SAT 59

BOS ATL 250 DFW 250

DFW ATL 250 AUS 59 BOS 250 HOU 128 LAX 1000 LIT 59 MSY 128 OKC 59 SHV 59 SFO 1200

HOU AUS 59 DFW 128 SAT 59

LAX DFW 1000 SFO 100

LIT DFW 59

MOB ATL 59

MSY DFW 128

OKC DFW 59

SAT AUS 59 HOU 59

SFO DFW 1200 LAX 100

SHV DFW 59

   Put your source file(s) into a .zip file called project5.zip

   and submit only the .zip file.

void dijkstra( Vertex s )

{

    for each Vertex v

    { v.dist = INFINITY; v.known = false; }

    s.dist = 0; // start source vertex at distance zero

    for (; ;) {

          Vertex v = smallest unknown distance vertex

          if ( v == null)

               break;

          v.known = true;

          for each Vertex w adjacent to v

              if (!w.known)              

                    if (v.dist + cvw < w.dist) // cvw is cost from v to w

                    {     // update w

                           decrease (w.dist to v.dist + cvw);

                           w.path = v;

                     }

              }

     }   

}

void printPath ( Vertex v)
{

   if ( v.path !=null )
   
   {
    printPath( v.path );
    System.out.print( " to " );
}

System.out.print( v );
}

Explanation / Answer

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote