Thread: Help needed.

  1. #1
    Registered User
    Join Date
    Sep 2005

    Help needed.

    I need some help with this program. I have posted what I have so far below. If you will look over it and give me any advice as to what I need to do based on these specifications:
    PROBLEM : An airline flies between six cities. Whether or not there
    is a direct flight from one city to another is indicated
    in a table found in a data file called flights.241.
    The table will have the following appearance, except the
    row and column designators will not be present:

    1 2 3 4 5 6

    1 F T T F F T
    2 T F T F F T
    FROM: 3 F F F T F F
    4 F T F F T F
    5 F T F T F F
    6 F T F F T F

    On the left and across the top are the number codes of the cities.
    If there is a T at the intersection of a row and column, then
    there is a direct flight from the city marked on the left to
    the city indicated at the top. An F indicates that there is
    no direct flight between the two cities. The key of the city
    names will follow the flight ( T-F ) matrix in the data file.
    It will consist of six names, the first coinciding with matrix
    code number 1, the second with number 2, etc.

    Another file called customer.241 will contain a customer name,
    customer number, and a request for a flight pattern. The
    flight pattern indicates the cities between which that customer
    wishes to fly. For example, a pattern of 13426 indicates that
    the customer wishes to fly from city 1 to city 3, then from city
    3 to city 4, then to city 2, and finally to city 6. The maximum
    number of cities in a flight pattern is five. If a customer has
    less than five cities in a flight pattern, then the remaining
    fields are filled with zeros. Thus, a pattern of 62000
    indicates that the customer wishes to fly from city 6 to
    city 2 and does not wish to continue beyond that. The customer
    file will have the following format:

    (Cols 1 - 25) (Cols 26 - 30) (Cols 31 - 35)

    John Smith 10232 13426

    Write a C++ program that reads the flight matrix data and
    city names from the flight file, reads the customer request
    information from the customer file, prints at the top of a new
    page the flight matrix with city labels, determines if each
    customer's requested flight pattern is possible, and prints
    a table containing the customer's names, flight patterns,
    customer numbers, and a statement indicating whether or not a
    ticket may be issued for the desired pattern.

    #include <iostream>
    #include <fstream>
    using namespace std;
    //prototype function headers
    void Filecheck(ifstream&, char[]);
    void ReadCities(ifstream&, char[6][6]);
    void PrintOut(char[6][6]);
    int main()
      char flights[6][6];
      ifstream Input;
      ofstream Out;
      char Cities;
    ReadCities (Input, Cities);
    //PrintOut (Cities);
    return 0;
    void Filecheck(ifstream& In, char Name[])
        cout << "File not found\n";
        cout << "Enter file name >";
        cin >> Name;;
    void ReadCities(ifstream Input, char Cities[6][6])
      int i=0;
      int j=0;
    while (!Input.eof())
    for (i = 0; i < 6; i++)
    	for (j = 0; j < 6; j++)
        	Input >> Cities[i][j];
    void PrintOut(char Cities[6][6])
      int i=0;
      int j=0;
    for (i=0; i<6; i++)
    	for (j=0; j<6; j++)
    		cout << Cities[i][j] << " ";
            cout << endl;

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Is this homework?

    Looking at the data file,
    F T T F F T
    I think the letters are separated by spaces. Therefore,
    for (i = 0; i < 6; i++)
    	for (j = 0; j < 6; j++)
        	Input >> Cities[i][j];
    should be modified to skip over spaces.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Jan 2005
    >> should be modified to skip over spaces

    That code already skips over spaces. No change is necessary there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. Help Please
    By Moose112 in forum C++ Programming
    Replies: 9
    Last Post: 12-10-2006, 07:16 PM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  5. semi-colon - where is it needed
    By kes103 in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2003, 05:24 PM