Following those six lines are an indeterminate number of lines, |
I am given a text file where the first six lines will always be in the format <Party affiliation> <Position sought> <Full name> where <Party affiliation> is either Fieldite or Nullifier, <Position sought> is one of Auditor, Coroner, or Recorder, and <Full name> is the candidates full name as they want it listed. Votes may be cast for fringe candidates. Following those six lines are an indeterminate number of lines, each of which represents a vote for a particular candidate for office. The votes, as they come out of the voting machine, are in the format: <Position code> <Party voted for> where Position code is one of the valid codes A,C, or R (in upper or lower case) or some other letter that represents a mistake. Party voted for is one of the major parties coded as a N or F, or some other minor party represented by some other code. Here is an example of a text file: Fieldite Recorder Clayton R. Raschke Nullifier Recorder Roslyn Blumberg Fieldite Coroner L. N. Cataldo Nullifier Auditor Kelly Corrao Nullifier Coroner Melisa Kinkade Fieldite Auditor Julianne Winzer C F A F C F A F R F A F R F R N A F A F C F C G C F A G The output should be a table that shows, for each position, the name and party of the winning candidate first; the name and party of the losing candidate second; and the sum of votes cast for other candidates. It should also show the count of miscast votes that were for a non-existant position code. I am at a complete halt here and I feel like I am going down the wrong path completely. I am especially having problems with looping and sorting the first six lines of the file so that it can be sorted easily. Any help would be much appreciated! I am very new to C++. This is all the code I have managed to get but I am in need of some serious guidance.
|