Write Program Election Computes Tally Write Election Announces Winner Since Votes Write Pr Q43833382
Write a program Election that computes the tally in a write-inelection, and announces the winner. Since the votes are write-in,there is no pre-determined set of candidates. Whoever appears themost in the votes is the winner. The user enters the individualvotes, one vote per line, and ends entering with typing -1 or anempty line. To compute the tally, the program uses two arrays, aString [ ] variable (names), and an int [ ] variable (count). Uponreceiving a single vote, the program checks if the name on the voteappears in names, and if it does, the program adds 1 to the valueof the element in count. If the name does not appear in names, theprogram extends both arrays by one element, stores the name innames at the last position and store 1 in count at the lastposition. In this manner, the two arrays will have the samelengths. The initial length is 0 for both arrays. Below is anexample of how the program may run
please I need to demonstrate the code,I need some comments nextto every single line
thanks:
####################################### # Enter the votes, one vote per line. # # End with either -1 or an empty line. # ####################################### Sam Peter James Sam Sam Peter Sam Sam recieved 4 votes Peter recieved 2 votes James recieved 1 votes – – – – – – – – – – – – – – – – – – – – – – – – The winner is Sam with 4 votes Show transcribed image text ####################################### # Enter the votes, one vote per line. # # End with either -1 or an empty line. # ####################################### Sam Peter James Sam Sam Peter Sam Sam recieved 4 votes Peter recieved 2 votes James recieved 1 votes – – – – – – – – – – – – – – – – – – – – – – – – The winner is Sam with 4 votes
Expert Answer
Answer to Write a program Election that computes the tally in a write-in election, and announces the winner. Since the votes are w…
OR