Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a program that determines the results of an election by selecting the person with the largest numberofvotesasthe winner.Youhavebeen provided withatextfile called Election_Results.txt, which
1. Write a program that determines the results of an election by selecting the person with the largest numberofvotesasthe winner.Youhavebeen provided withatextfile called "Election_Results.txt", which provides results for 5 candidates. Itlists the name of each candidate followed by the "lt (tab char)and the numberof votes the candidate received. Yourprogram should read the information fromthe file. Use one array to store the candidates name and another to store the number of votes he/she received. To read strings with spacesyou willneed tousethe getlinefunction Example: getline ilename, 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 mani to print these in a table format on the console as shown below. Your program should also output the winner of the election. See sample output below Name Devorah Chickering Timothy Mulqueen Arlette Honeywel1 Dominque Dickerson Lettie Isenhower otes 458ee 2880e 6580e 1580e 55880 Percent 22.5% 18. 0% 32.5% 7.5% 275% Total votes: 288008 The winner of the election is: Arlette Honeywel.1
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