Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5. int main() {
  6. //start
  7. /*int n;
  8. cout << "number of candidates: ";
  9. cin >> n;
  10. system("cls");*/
  11. //screen 1
  12. string name[10];
  13. float votes[10];
  14. float totalSum = 0;
  15. int i;
  16. int CNo = 1;
  17. cout << "Voting System" << endl;
  18. for (i = 0; i < 10; i++) {
  19. cout << "Candidate " << CNo << ": ";
  20. CNo++;
  21. getline(cin, name[i]);
  22. cout << "Votes: ";
  23. cin >> votes[i];
  24. cin.ignore();
  25. }for (i = 0; i < 10; i++) {
  26. totalSum += votes[i];
  27. }
  28. system("cls");
  29. //screen 2
  30. CNo = 1;
  31. for (i = 0; i < 10; i++) {
  32. float percent = votes[i] / totalSum * 100;
  33. cout << "Candidate " << CNo << ": " << name[i] << "\t\t" << "Votes: " << votes[i] <<"\t\t" << setprecision(2)<< "Percentage: " << percent << "%" << endl;
  34. CNo++;
  35. }cout << "Continue? (Y/N)" << endl;
  36. ;
  37. //input for Continue
  38. char q;
  39. cin >> q;
  40. if(q == 'Y' || q == 'y'){
  41. goto Continue;
  42. }else{
  43. exit(0);
  44. }Continue:
  45. cout << "SUMMARY" << endl;
  46. cout << "Number of Votes = " << totalSum << endl;
  47. ;
  48.  
  49. system("pause");
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement