Title | Source code 1.10 Lab: Airports 2 |
---|---|
Course | Intermediate Programming Methodologies in C++ - HONORS |
Institution | De Anza College |
Pages | 1 |
File Size | 48.1 KB |
File Type | |
Total Downloads | 57 |
Total Views | 136 |
Source code 1.10 Lab: Airports 2
Data about airports are stored in three parallel arrays: one array contains airport codes (in ascending order), such as LAX, another array contains the names of the cities served, such as Los Angeles, and the third array contains the number of enplanements (com...
code: 1.10 Lab: Airports 2 #include #include using namespace std; /* Write your code here */ void displaySearchHistory(int [], string [], string [], int [],int); int binarySearch(string[],string,int,int); int main(){ //constants definitions const int AIRPORTS = 50; // maximum size of arrays // arrays definitions string city[AIRPORTS] = {"Burbank", "Fresno", "Los Angeles", "Oakland", "Redding", "San Jose", "Santa Ana"}; string code[AIRPORTS] = {"BUR", "FAT", "LAX", "OAK", "RDD", "SJC", "SNA"}; int numOfEnpl[AIRPORTS] = {100433, 761298, 39636042, 5934639, 43414, 5321603, 5217242}; int searchCount[AIRPORTS]={0}; // to keep track of the search history -intialize it to 0 { if you don't intialize a value it would tak // other variables int size = 7,l=0; // actual size of arrays string targetAirport[] = {"SJC", "BUR", "SJC", "LAX", "ACV", "SJC", "LAX", "BUR", "BUR", "SJC", "LAX", "SJC", "BUR", "RDD", ""};
for (int i = 0; targetAirport[i] != ""; i++){ /* Write your code here */ int val=binarySearch(code,targetAirport[i],l,size); if(val!=-1){ searchCount[val]=searchCount[val]+1;} } displaySearchHistory(searchCount, code, city, numOfEnpl,size); return 0; } /* Write your code here */ void displaySearchHistory(int searchCount[50], string code[50], string city[50], int numOfEnpl[50], int size) { cout...