// Ch. 14 Demo #4
// Purpose - to illustrate the use of parallel vectors


#include <iostream.h>
#include <fstream.h>
#include "M:\C++ Programming\AP classes\apvector.h"
#include "M:\C++ Programming\AP classes\apstring.h"

int main()
{
	apvector <apstring> names(5, "no name");
	apvector <int> scores(5, 0);
	int i = 0;
	apstring name;
	ifstream infile("studentdata.txt");

	cout << "The names and corresponding scores of five students are "
		<< "being read from a file." << endl;
	
	for (i = 0; i < 5; i++)
	{
		infile >> names[i];
		infile >> scores[i];
	}

	cout << "What is the name of the student whose score you'd like to find? ";
	cin >> name;

	for (i = 0; i < 5; i++)
	{
		if (names[i] == name)
		{
			cout << "His/her score is " << scores[i] << endl;
			break;
		}

	}

	return 0;
}// end of main