Challenge 27b

Description

The purpose of this challenge is load a tokenized file. This challenge loads a file of airport codes and allows the user to query its contents.

 Requirements

  1. Using vi, create a text file, airports.txt, that will contain the following data as shown below. You don’t have to write code to create this file. Ask yourself, Why do the cities with multiple words use a dash instead of an actual space? (Los-Angeles instead of Los Angeles)
    BFL Bakersfield 3
    LAX Los-Angeles 35
    GRV Grozny 8
    IAH Houston 23
    MGA Managua 11
    -LGA La-Guardia 37
    AGU Aguascalientes 12
    -BER Berlin 16
    JFK New-York 36
    RKV Reykjavik 1
    DEL Delhi 3
    -DXB Dubai 3
    BOG Bogota 2
  2. In main, declare an array of strings, cities[20]
  3. Using a function int read_airports(string cities[], int minimum). This function will read the airports.txt file. As you read the entire file, identify which airports have at least minimum terminals and store the corresponding city names into the cities array. This function will also return the number of cities found whose number of terminals is at least minimum. If the airport code starts with a hyphen (-), that means that airport is unavailable or out of service temporarily; Do not include any out-of-service airport in your listings — Do not add this airport into the array.   Do not cout in this function. Use the cities array to hold the qualifying city names. Use main() to display the contents of the cities array. Ask yourself, why does this function return the number of qualifying cities? 
  4. Ask the user to enter an integer which represents the minimum number
  5. Display the cities found. Make sure you display the qualifying cities from main(). Consider the possibility that the cities array may not be completely filled with names – only display the names filled in by the read_airports function. 

Sample main()

int main()
{
  string cities[20];
  int count, minimum;

  // ask the user to enter a minimum number
  cout << "Enter a minimum number: ";
  cin >> minimum;

  count = read_airports(cities, minimum);

  // show the cities that have at least minimum number of terminals
  // TODO
   
  return 0;
}

Sample Interaction

Enter a minimum number: 20
The following airports have at least 20 terminals:
Los-Angeles
Houston
New-York

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-CHAL0027b

Print Requirements