Guest User

Untitled

a guest
Jan 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. Write a program that reads data from a file named votedata.txt which you create. The first number in the file indicates how many candidates ran in the election. The capacity of the program will be to handle 20 candidates. For each candidate will be their last name (we will assume one word last names only) and the number of votes each received. The program should then output each candidate's name, the number of votes received, and the percentages of the number of votes received by the candidate. Your program should also output the winner of the election. A sample output is:
  2.  
  3. Candidate Votes Received % of Total Votes
  4.  
  5. Johnson 5000 25.91
  6. Miller 4000 20.73
  7. Duffy 6000 31.09
  8. Robinson 2500 12.95
  9. Ashtony 1800 9.33
  10. Total 19300
  11.  
  12. The Winner of the Election is Duffy.
  13.  
  14.  The input should come from the file.
  15.  Use arrays to store the names, votes, and percentages before they are displayed.
  16.  Include functions
  17. o inputValues to input values for candidate names and votes received and place them in arrays.
  18. o calcPercents which fills an array with the percentage of votes each candidate got.
  19. o determineWinner which returns the name of the winner. It is passed the percentage array and name array.
  20. o displayResults which displays on the screen the output as shown.
  21.  All arrays are declared in the main( ) function. Arrays are passed to a function should the function need to process them.
Add Comment
Please, Sign In to add comment