// Justin C. Miller
// University of Wisconsin Oshkosh
// Made for: http://www.geocities.com/neonprimetime.geo/index.html
// Date: 2001
// Borland Builder 4.0
#include 
#include 
#include 
#include 
#include 

void GetFileName(char []) ;
void party(char) ;
void PrintHeader(char []) ;

int main()
{
	char filename[50] ;

	GetFileName(filename) ;

	ifstream in ;
	in.open(filename) ;
	
	int numberOFfiles ;
	in >> numberOFfiles ;

	int dvotes = 0 ;
	int rvotes = 0 ;
	int ovotes = 0 ;

	for(int i = 0 ; i < numberOFfiles ; i++)
	{
		char filename2[50] ;
		in >> filename2 ;
		ifstream newin ;
		newin.open(filename2) ;

		PrintHeader(filename2) ;

		char  politicalparty ;
		int votes ;
		int issue ;
		while(!newin.eof())
		{
			// read them in
			newin >> politicalparty ;
			newin >> votes ;
			newin >> issue ;
			// count total votes
			if(politicalparty == 'D')
				dvotes = dvotes + votes ;
			if(politicalparty == 'R')
				rvotes = rvotes + votes ;
			if(politicalparty == 'O')
				ovotes = ovotes + votes ;
			// print them out
			party(politicalparty) ;
			cout << setw(8) << votes << " " << issue << endl ;
		
		}
		newin.close() ;
		getch() ;
	}
	cout << endl ;
	cout << setiosflags(ios::left) << setw(12) << "totals" << " college" << endl ;
	cout << setw(12) << " " << " votes" << endl ;
	cout << "==========================" << endl ;
	cout << setiosflags(ios::left) << setw(15) << "democrat " << dvotes << endl ;
	cout << setiosflags(ios::left) << setw(15) << "repub " << rvotes << endl ;
	cout << setiosflags(ios::left) << setw(15) << "other " << ovotes << endl ;


	getch() ;

	return 0 ;
}


void GetFileName(char x[]) 
{
	cout << "Please enter in the file name to open up!" << endl ;
	cin >> x ;
}

void party(char x)
{
	if(x == 'D')
		cout << setiosflags(ios::left) << setw(15) << "democrat " ;
	if(x == 'R')
		cout << setiosflags(ios::left) << setw(15) << "repub " ;
	if(x == 'O')
		cout << setiosflags(ios::left) << setw(15) << "other " ;
}

void PrintHeader(char f[]) 
{
	cout << endl ;
	cout << setiosflags(ios::left) << setw(12) << f << " college major" << endl ;
	cout << setw(12) << " " << " votes   issue " << endl ;
	cout << "==========================" << endl ;
}

    Source: geocities.com/neonprimetime.geo/cpp/cpp_SourceCode

               ( geocities.com/neonprimetime.geo/cpp)                   ( geocities.com/neonprimetime.geo)