Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that allows the user to enter the last names of five candidates

ID: 3761521 • Letter: W

Question

Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by each candidate. The program should then output each condidate's name, votes received by that candidate, and the percentage of the total votes recieved by the candidate. Your program should also output the winner of he election. A sample output is as follows:

Candidate           Votes                % of Total Votes

Johnson             5000                   25.91

Miller                  4000                  20.72

Duffy                  6000                  31.09

Robinson           2500                  12.95

Sam                   1800                   9.33

Total                    19300         

The Winner of the Election is Duffy.

Explanation / Answer

#include #include #include using namespace std; int main() { //******************************************************************** //declare variables //******************************************************************** int counter = 0; //to loop through the arrays int sum = 0; //the total number of votes cast double percentage = 0; int arraySize = 0; int maxVotes = 0; int counterMax = 0; //declare dynamic arrays string *names; int *votes; //******************************************************************************** //prompt user for the array size and create arrays //******************************************************************************** cout > arraySize; // if input is of the wrong data type we must terminate while (!cin) { cin.clear(); cin.ignore(200, ' '); cout > arraySize; } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote