The presidential election for the student council of your local university will
ID: 3633422 • Letter: T
Question
The presidential election for the student council of your local university will be held soon. For reasons related to confidentiality, the chair of the election committee wants to computerize the voting. The chair is looking for someone to write a program to analyze the data and report the winner. Let us write a program to help the election committee.
The university has four major divisions, and each division has several departments. For the purpose of the election, the four divisions are labeled as Region 1, Region 2, Region 3, and Region 4. Each department in each division manages its own voting process and directly reports the votes received by each candidate to the election committee. The voting is reported in the following form:
Candidate-name region# number_of_votes_for this_candidate
Below is input specification:
===============================================================
Name Region 1 Region 2 Region 3 Region 4
------ ---------- ---------- ----------- -----------
Balto 0 0 0 272
Doc 25 71 156 97
Sally 38 88 5 101
Raju 115 75 20 33
Rema 49 71 18 0
The election committee wants the output in the following tabular form:
---------------------- Election Results ----------------------
Candidate Votes
Name Region 1 Region 2 Region 3 Region 4 Total
------------ ---------- ---------- ----------- ----------- -------
Balto 0 0 0 272 272
Doc 25 71 156 97 349
Sally 38 88 5 101 ?
Raju 115 75 20 33 ?
Rema 49 71 18 0 ?
Winner: ??? Votes Received: ???
Total votes polled: ???
Execute a program using the given input(store the data in text document)specification to produce a bubble sorted output(produce the output in txt document) specification.
Explanation / Answer
Function getCandidatesName void getCandidatesName(ifstream& inp, string cNames[], int noOfRows) { int i; for(i = 0; i >cNames[i]; //read candidate_name } Function sortCandidatesName • This function uses selection sort algorithm (As discussed in this chapter) to sort the array candiatesName. void sortCandidatesName(string cNames[], int noOfRows) { int i, j; int min; //selection sort for(i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.