Frustrated...help!
UPDATE
Well I got the Validate lists working perfectly and it got the correct registered.txt output. my problem now is this
void PrecinctBreakdown(int num, int& republican, int& democrat) {
republican = 0;
democrat = 0;
int regnum, area;
char party;
ifstream registered;
registered.open("registered.txt");
registered >> regnum >> area >> party;
while (! registered.eof( )) {
if ((area == num) && (party == 'R'))
republican++;
else if ((area == num) && (party == 'D'))
democrat++;
registered >> regnum >> area >> party;
}
registered.close( );
return;
}
I can get output, but according to the sample output and my registered.txt file I'm getting the opposite of the true information. Example: I query for the number of republicans and democrats in an area, if the goal output is 0 democrats and 3 republicans, I get 3 democrats and 0 republicans. Strange logic error somewhere in there...if you can help, thanks.
Well I got the Validate lists working perfectly and it got the correct registered.txt output. my problem now is this
void PrecinctBreakdown(int num, int& republican, int& democrat) {
republican = 0;
democrat = 0;
int regnum, area;
char party;
ifstream registered;
registered.open("registered.txt");
registered >> regnum >> area >> party;
while (! registered.eof( )) {
if ((area == num) && (party == 'R'))
republican++;
else if ((area == num) && (party == 'D'))
democrat++;
registered >> regnum >> area >> party;
}
registered.close( );
return;
}
I can get output, but according to the sample output and my registered.txt file I'm getting the opposite of the true information. Example: I query for the number of republicans and democrats in an area, if the goal output is 0 democrats and 3 republicans, I get 3 democrats and 0 republicans. Strange logic error somewhere in there...if you can help, thanks.
