pazryx

C8P1 v01

May 1st, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string name[5];
  11. double votes[5];
  12. double percent;
  13. int entry = 0;
  14. int total = 0;
  15.  
  16. cout << "For five turns, enter a last name and a number of votes.\n\n";
  17.  
  18. do{
  19. cin >> name[entry];
  20. cin >> votes[entry];
  21. entry++;
  22. }while(entry < 5);
  23.  
  24. entry = 0;
  25.  
  26. cout << "Here are the results for this election:\n\nCandidate" << " " << "Votes" << " " << "Percent\n";
  27.  
  28. do{
  29. total += votes[entry];
  30. entry++;
  31. }while(entry < 5);
  32.  
  33. entry = 0;
  34.  
  35. do{
  36. cout << name[entry] << setw(7) << votes[entry];
  37. percent = ( votes[entry] / total ) * 100;
  38. cout << setw(7) << percent;
  39. cout << "\n";
  40. entry++;
  41. }while(entry < 5);
  42.  
  43. cout << "Total votes: " << setw(7) << total;
  44.  
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment