#include #include using namespace std; int main() { ifstream infile; // data file const unsigned n = 4; // number of candidate birds unsigned counts[ n ] = { 0 }; // ballot totals per bird unsigned precinct, bird, votes; // Read counts from input file and update totals infile.open( "votes.dat" ); while ( infile >> precinct >> bird >> votes ) counts[ bird ] += votes; // update vote count infile.close(); // Print vote totals to the standard output cout << "Vote totals are:" << endl; for ( unsigned i = 0; i < n; i++ ) { switch ( i ) { case 0: // pigeon cout << "Pigeon: "; break; case 1: // mourning dove cout << "Dove: "; break; case 2: // falcon cout << "Falcon: "; break; case 3: // robin cout << "Robin: "; break; } cout << counts[ i ] << endl; } return 0; }