Computer Science Homework Solutions
Problem
#104590

Election Vote Program in C++

1.  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, and the percentage of the total votes received by the candidate.  Your program should also output the winner of the election.  A sample output is:

Candidate Votes Received % of Total Votes
Johnson 5000 25.91
Miller 4000 20.72
Duffy 6000 31.09
Robinson 2500 12.95
Anthony 1800 9.33
Total 19300

The Winner of the Election is Duffy.


Solution Summary

Following is the Detailed explanation and solution of the Election Program. Basically, there are three functions other than main(). They are called from main. Also note that calculate_winner() is basically a majority finder. It does not know what to do in case of a tie.

I have attached both the code and the executable for your benefit.

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$19.95)
Included in Download
  • Plain text response
  • Attached file(s):
    • 104590-election.cpp
    • 104590-election.exe
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Web Site Structures - Describe Web site structures and the purpose of each structure.
  • C+ programming - useing a loop and switch statement. In this program, you will keep track of the number of votes for each color of m&m's candy. The user will be able to vote until he types the sentinal character 9. Di ...
  • Control Structures - You are an accountant setting up a payroll system for a small firm. Each line of the table in Appendix G indicates an employee’s salary range and corresponding base tax amount and tax percentage. Give ...
  • Write a program whose main function is merely a collection of variable declarations and function calls. - Please see attached file. Write a program whose main function is merely a collection of variable declarations and function calls. This program reads a text and outputs the letters, together with t ...
  • Data Structures C++ - Implement the recursive version of the binary search algorithm in C++. Write the code to test it out on a sample input.
Browse