Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

Election_Results.txt

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

=+ a. a family deciding whether to buy a new car

Answered: 1 week ago

Question

=+10. How are inflation and unemployment related in the short run?

Answered: 1 week ago