Question: C++ Program Write a program that determines the results of an election by selecting the person with the largest number of votes as the winner.

C++ Program

Write a program that determines the results of an election by selecting the person with the largest number of votes as the winner. You have been provided with a text file called "Election_Results.txt", which provides results for 5 candidates. It lists the name of each candidate followed by the '\t' (tab char ) and the number of votes the candidate received. Your program should read the information from the file. Use one array to store the candidate s name and another to store the number of votes he/she received. To read strings with spaces you will need to use the ge tline function. Example: getline(filename, string variable, delimiter char); Your program should then determine the winner, and output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate and use manipulators from to print these in a table format on the console as shown below. Your program should also output the winner of the election.

Sample Output:

Devorah Chickering 45000 Timothy Mulqueen 20000 Arlette Honeywell 65000 Dominque Dickerson 15000 Lettie Isenhower 55000 

Total Votes is 200000

The winner is Arlette Honeywell

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!