You are to write a program that:  1. Prompts a user to enter the name of an input file.  2. This input file should then be read in. The input file represents a data file for a network of
    You are to write a program that:  1. Prompts a user to enter the name of an input file.  2. This input file should then be read in. The input file represents a data file for a network of

You are to write a program that: 1. Prompts a user to enter the name of an input file. 2. This input file should then be read in. The input file represents a data file for a network of

$20.00

Problem Description

You are to write a program that:

1. Prompts a user to enter the name of an input file.

2. This input file should then be read in. The input file represents a data file for a network of

airports and flights, as follows:

  • The first line of the input file will be the number of airports (vertices) in the system for the purposes of this document, call this value n (you might want to come up with something more descriptive in your code). You are guaranteed that n will be no more than 100.
  • The next n lines of the input file will each contain a single airport name (you may assume that no airport name contains any kind of whitespace and has no more than 25 characters in it).
  • The next line will contain an integer representing the number of flights (edges) that currently exist between airports; for the purposes of this document, call this value m.
  • The next m lines of the input file will each represent a single direct flight between two airports (using the names specified in the first part of this input file). Each line will represent exactly one flight, and will be formatted as a follows:
    • the name of the originating airport, which is a string of no more than 25 characters.
    • the name of the destination airport, which is a string of no more than 25 characters
    • the cost of this flight, specified as an integer dollar amount.

Note that a flight going in one direction does not automatically imply a flight going

in the opposite direction. You are also guaranteed that there will be no “conflicting”

information; that is, a direct flight will not be represented more than once in the input

file.

3. Prompts the user with the following menu:

1) Find the cheapest flight between two airports

2) Quit

4) Prompts the user to choose one of these options.

5) If the user chooses the first option, the program should prompt the user to enter the names of

two airports (as found in the input file). The program should then print out the minimum cost

itinerary (containing at least one, but possibly many more flights) between the two airports.

This itinerary should print out the total cost (i.e. the sum of the costs of the involved

flights) and print out the actual individual flights and their costs. You are guaranteed that

no itinerary will cost more than $999,999 in total.

6) If the user chooses the third option, the program should terminate.

7) Goes back to step 3 (unless quit was previously chosen).

 

Example Run

Suppose the file test.in contains the following:

3

STL

LGA

MIA

5

STL MIA 269

STL LGA 139

MIA LGA 69

LGA MIA 89

LGA STL 149

Next, you run the program with this file as input in the following (with plain text representing output

and italicized text representing input):

What is the name of your input file? test.in

1) Find the cheapest itinerary between two airports

2) Quit

==> 1

The cost of the minimum flight is $228

STL to LGA $ 139

LGA to MIA $ 89

1) Find the cheapest itinerary between two airports

2) Quit

==> 2

Note that the above is a rather simple test; it is up to you to come up with test cases where

the cheapest itinerary might involve many more flights (for example, one that involves all of the

possible airports, even with a direct flight available).

Use Edsger Dijkstra’s algorithm.

A++ solution for this question

Solution contain C++ program and input data.

Using DevC++ IDE to run program.

If you want run on Visual studio, you can edit some lines in source code (i can help you do it).

Attached Files

Move over [ preview ] file name to preview content in it!

Write a review

Your Name:


Your Review: Note: HTML is not translated!

Rating: Bad           Good

Enter the code in the box below:



Tags: C++
PURCHASE SAVE
2 Tutorials 10%
3 Tutorials 13%
4 Tutorials 16%
5 Tutorials 19%
6 Tutorials 22%
7 Tutorials 25%
8 Tutorials 28%
9 Tutorials 31%
10 Tutorials 34%
add url more

9MZQASHWN73B