Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- #include <iomanip>
- using namespace std;
- int main()
- {
- string name[5];
- double votes[5];
- double percent;
- int entry = 0;
- int total = 0;
- cout << "For five turns, enter a last name and a number of votes.\n\n";
- do{
- cin >> name[entry];
- cin >> votes[entry];
- entry++;
- }while(entry < 5);
- entry = 0;
- cout << "Here are the results for this election:\n\nCandidate" << " " << "Votes" << " " << "Percent\n";
- do{
- total += votes[entry];
- entry++;
- }while(entry < 5);
- entry = 0;
- do{
- cout << name[entry] << setw(7) << votes[entry];
- percent = ( votes[entry] / total ) * 100;
- cout << setw(7) << percent;
- cout << "\n";
- entry++;
- }while(entry < 5);
- cout << "Total votes: " << setw(7) << total;
- return 0;
- }
Add Comment
Please, Sign In to add comment