#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <conio.h>
#include <cstring>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int searchVector(vector<string> QueryArray, string value){
for (int i = 0; i < QueryArray.size(); ++i)
if (QueryArray[i] == value)
return i;
return -1;
}
int main()
{
string line;
vector<string> QueryArray;
ifstream myfile("colleges.txt");
if(!myfile) //Always test the file open.
{
cout << " Error opening " << endl;
system("pause");
return 1;
}
while (getline(myfile,line))
{
QueryArray.push_back(line);
}
cout << QueryArray[4564] << endl;
int Colleges;
cout << "Welcome to My College and University summary program" << endl;
cout << "Press 1 to enter possible colleges and universities and the program will tell you if they appear on the list " << endl;
cout << "Press 2 to find out how many colleges or universities appear in the state of your choice" << endl;
cout << "Press 3 to find out how many colleges and universities appear in our list in total" << endl;
cout << "Press 4 to quit" << endl;
cin >> Colleges;
if (Colleges == 1)
{
string search_word;
cout << "What University would you like to find?" << endl;
cin >> search_word;
getline(cin, search_word);
if (std::find(QueryArray.begin(), QueryArray.end(), search_word)!= QueryArray.end())
{
returntrue;
returnfalse;
cout << "The word was found*** this part is not working properly***" << search_word << endl; }
else {
cout << "---------The Matrix not found*** its not finding the words correctly*** ------------ " << endl;
}
}
elseif (Colleges == 2)
{
{
string line2;
int SIZE = 4564;
string STATE[SIZE];
ifstream file2 ("states.txt");
if (file2.is_open())
{
int i = 0;
while (file2 >> line2 )
{
STATE[i] = line2;
i++;
}
file2.close();
}
else cout << "Unable to open file";
}
constint numStates = 4564;
string STATES[numStates];
//find out the number of any particular state in the array
cout << "Enter a state's abbreviation:" << endl;
string userState;
cin >> userState;
int stateCount = 0;
for(int i = 0; i < numStates; i++){
if(STATES[i] == userState)
{
stateCount++;
}
}
cout << userState << " has " << stateCount << " colleges." << endl;
}
else
cout << "There are 4564 Universities available to pick from!" << endl;
return 0;
}