Question: With C++ 2. [20 points] Write a program that allows to read from a file the last names of the candidates in an election and

With C++  With C++ 2. [20 points] Write a program that allows to

2. [20 points] Write a program that allows to read from a file the last names of the candidates in an 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 in descending order. Your program should also output the winner of the election. A sample output is: Candidate Johnson Brown Miller Duffy Robinson Votes Received 6000 5000 4000 2500 1800 % of Total Votes 31.09 25.91 20.73 12.95 9.33 Total 19300 The Winner of the Election is Johnson Your program should have the following functions: (a) Write a function openFile that prompts a user to enter a file name and opens it. (b) Write a function getData that reads from the file the candidate names and their number of votes received and returns them in 2 separate arrays. number of votes and returns an array of percentages of votes array of names, the arrays of the number of votes, and the array of percentages), and (c) Write a function computePercentages that takes as its parameter an array of (d) Write a function sortVotes that takes as its parameters the three arrays (i.e, the sort them in descending order of the number of votes or percentages. (e) Write a function display that displays the candidate names, their number of votes received, their percentages in descending order, and the total number of votes, as formatted above. (f) Write a function displayWinner that displays the winner of the election

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To accomplish the task well create a program in C following the specifications given Heres a stepbystep solution including all required functions cpp include include include include include include us... View full answer

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!