Tallying Votes
Construct a program to tally votes in an election.
Names for candidates 1 through 4 are stored in a file candnams.dat:
Grey
Mastrekova
Quirot
Rodal
E.g. candidate 1 is Grey...
Vote are stored in a file votes.dat with each integer representing a vote for
the corresponding candidate. Integers less than 1 or greater than 4 are invalid.
1 4 3 2 1 2 4 4 2 4 2 4 12 2 3 3 4 2 2
5 2 3 4 2 1 4 2 3 1 2 2 4 4 2 2 1 4 4
3 1 2 4 2 1 4 2 4 3 4 2 1 3 2 2 3 4 2 2
4 1 4 3 4 3 2 2 1 2 3 3 2 3 2 3 4 1 2 4
2 4 1 2 4 2 1 3 3 4 2 1 3 4 2 4 24 1 2
1 4 2 4 3 3 4 1 2 3 2 3 3 3 2 4 4
Output for this data:
Invalid vote: 12
Invalid vote: 5
Invalid vote: 24
CANDIDATE NO. OF VOTES
Grey 17
Mastrekova 38
Quirot 24
Rodal 32