1.

Practical Activity 4 (Election)Write a program Election that computes the tally in a write-in election, and announces thewinner. Since the votes are write-in, there is no pre-determined set of candidates. Whoeverappears the most in the votes is the winner. The user enters the individual votes, one voteper line, and ends entering with typing -1 or an empty line. To compute the tally, theprogram uses two arrays, a String [] variable (names), and an int [] variable (count). Uponreceiving a single vote, the program checks if the name on the vote appears in names, and ifit does, the program adds 1 to the value of the element in count. If the name does notappear in names, the program extends both arrays by one element, stores the name innames at the last position and store 1 in count at the last position. In this manner, the twoarrays will have the same lengths. The initial length is O for both arrays.Below is an example of how the program may run:Enter the votes, one vote per line. :| End with either -1 or an empty line. ISamPeterJamesSamSamPeterSamSam recieved 4 votesPeter recieved 2 votesJames recieved 1 votesThe winner is Sam with 4 votes​

Answer»

ANSWER:

idk

Explanation:



Discussion

No Comment Found