Function Name: voteCounter
Inputs (1): - (char) filename of votes
Outputs (0): - none
Function Description:
You use the brand new VoteMaster 3000 to tally up votes in the recent
elections of some of your extracurricular organizations. To your dismay,
it only outputs a txt file with a title describing the election and a
list of the candidates'' names, with each line representing a vote for
that candidate.
In addition to suing the VoteMaster 3000 makers for false advertising,
you now have to create a MATLAB function named voteCounter that takes in
the txt file of names and writes another txt file containing the
candidates and their respective votes, in descending order. Furthermore,
the filename of the written txt file should be the first line of the
input txt file.
For example, if the input txt file contained
1371 Head TA Elections
McGraw
Carter
Tahler
Bragg
Carter
your written txt file should be named ''1371 Head TA Elections.txt'' and contain
Carter 2
McGraw 1
Tahler 1
Bragg 1
Notes:
- in the written text file, there is a space between the candidate name
and his/her number of votes
- in the event of a tie, the candidate who appears first in the input
file wins (the sort function should take care of this)
- there should be no empty line at the end of your written file (i.e. the
last line of your written file should be the candidate who received the
least number of votes)
- PLEASE open the txt files in MATLAB to avoid confusion with new lines.