Question #38291

Problem:
A salesman travels from one to another state. he may visit either n=2,3,4,5 or 6 cities of punjab.
For every number of cities he may adopt different routes.
Some routes will be longer and other rwill be shorter.
We neeed to design a C++ Program.
*TO DISPLAY EACH ROUTE FOR PARTICULAR NUMBER OF CITIES "n".
*TO DISPLAY SHORTEST AND LONGEST ROUTE
Hint:
1:Develop a menu using switch
2: Enter tthe distance using two dimentional array.

I have made the switch menu but i dont know how to do it if anyone can help me out
1

Expert's answer

2014-01-22T10:12:00-0500

Answer on Question#38291- Programming, C++

1. Problem:

A salesman travels from one to another state. he may visit either n=2,3,4,5 or 6 cities of punjab.

For every number of cities he may adopt different routes.

Some routes will be longer and other rwill be shorter.

We need to design a C++ Program.

*TO DISPLAY EACH ROUTE FOR PARTICULAR NUMBER OF CITIES "n".

*TO DISPLAY SHORTEST AND LONGEST ROUTE

Hint:

1:Develop a menu using switch

2:Enter the distance using two dimensional array.

I have made the switch menu but i dont know how to do it if anyone can help me out

Solution.


#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
    int dist[6][2] = {0};
    cout << "Enter the distance: " << endl;
    for (int i = 0; i < 6; i++)
    {
        cout << "Start: ";
        cin >> dist[i][0];
        cout << endl << "End: ";
        cin >> dist[i][1];
    }
    int iMenu = 0, n = 0;
    cout << "1. Display the route for a particular city" << endl;
    cout << "2. Display the shortest and longest route" << endl;
    cout << "Enter your choice: ";
    cin >> iMenu;
    switch (iMenu)
    {
        case 1:
            cout << "Enter the number of cities: ";
            cin >> n;
            // Code to display route for particular city
            break;
        case 2:
            // Code to display shortest and longest route
            break;
        default:
            cout << "Invalid choice" << endl;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS