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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started