Question: Please fix the uploaded code. I get an error message when I compiler it. /// Header files section #include #include #include using namespace std; ///

Please fix the uploaded code. I get an error message when I compiler it.

Please fix the uploaded code. I get an error message when I

/// Header files section #include #include #include using namespace std; /// function prototypes void readCandidatesDetails (string lastNames[],int numberOfVotes [], int size); int getIndexofWinner(int numberOfVotes[], int size); int getTotalVotes (int numberofVotes[], int size) ; void printElectionResults (string lastNames [],int numberOfVotes [], int size, int index, int totalVotes); /// start main function int main () {

/// declare constant for the maximum number of /// candidates in the election const int ARRAY_SIZE = 5 /// create parallel arrays for the last names and /// the number of votes received string lastNames[ARRAY_SIZE]; int numberOfVotes[ARRAY_SIZE]; int winnerIndex; int totalVotes; /// ca1l the readCandidates Details function readCandidatesDetails (lastNames, numberOfVotes, ARRAY_SIZE); /// call the getIndexOfWinner function winnerIndex = getIndexofWinner(numberOfVotes, ARRAY_SIZE) ; /// call the getTotalVotes function totalvotes = getTotalVotes(numberOfVotes, ARRAY_SIZE); /// call the printElectionResults function printElectionResults (lastNames, numberOfVotes, ARRAY_SIZE, winnerIndex, totalVotes) ; return 0; } /// end of main function

/// readCandidatesDetails function prompts and reads /// the last name and the number of votes received for /// each candidate void readCandidatesDetails (string lastNames [], int numberOfVotes [ ], int size) {

/// repeat the loop to read the last name and /// the number of votes received of each candidate for (int i = 0; i

cout > lastNames [i]; cout > numberOfVotes [i]; } /// end of readCandidates Details method } /// get IndexOfWinner function finds and returns the index ///of the highest number of votes in the given array int get IndexofWinner(int numberOfVotes[], int size) {

/// local variables int index = 0; int maximum = numberofVotes [0]; /// find the index of the highest number of votes for (int i = 1; i

if (numberOfVotes [i] > maximum) {

maximum = numberOfVotes [il; index = i; }

} /// return the index of the highest number of votes return index; } /// end of getIndexOfWinner function /// getTotalVotes function computes and returns the total /// number of votes in the given array int getTotalvotes (int numberOfVotes [], int size) {

/// compute the total number of votes int totalNumberofVotes = 0; for (int i = 0; i

/// return the total number of votes return totalNumberofVotes; } /// end of getTotalVotes function ///printElectionResults function prints the election /// results in a table format void printElectionResults (string lastNames [], int numberOfVotes [], int size, int index,int totalVotes) {

cout

cout

cout Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the win- ner of the election. A sample output is: Candidate 7. Votes Received % of Total Votes Johnson Miller Duffy Robinson Ashtony Total 5000 4000 6000 2500 1800 19300 25.91 20.73 31.09 12.95 9.33 The Winner of the Election is Duffy

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!