Write a program that allows the user to enter the last names of five candidates
ID: 3638528 • 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 candidate’s name, the votes received by that candidate in descending order, and the percentage of that total votes received by that candidate (write the appropriate formula to calculate % of total votes). Your program should also output the winner of the election. A Sample output is:Candidate Votes Received % of the Total Votes
Johnson 5000 25.91
Miller 4000 20.72
Duffy 6000 31.09
Robinson 2500 12.95
Ashton 1800 9.33
Total 19300
The winner is Duffy.
Explanation / Answer
#include #include #include using namespace std; int main() { string name1, name2, name3, name4, name5; int votes1, votes2, votes3, votes4, votes5, totalvotes; int percent1, percent2, percent3, percent4, percent5; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.