Advertisement
ivanwidyan

Poll With 3 Possible Values and Print Results as Bar

Oct 17th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>  
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.     char input;
  7.     int PollAmount = 10;
  8.     string CatAmount = "", DogAmount = "", TurtleAmount = "";
  9.     do {
  10.         cout << "Poll Amount = " << PollAmount << endl;
  11.         cout << "Choose which animals do you like to pet: " << endl;
  12.         cout << "1. Cat" << endl;
  13.         cout << "2. Dog" << endl;
  14.         cout << "3. Turtle" << endl;
  15.         cout << "Submit the number: ";
  16.         cin >> input;
  17.         if (input == '1') {
  18.             cout << "You Chose Cat!" << endl;
  19.             PollAmount--;
  20.             CatAmount += "|";
  21.         }
  22.         else if (input == '2') {
  23.             cout << "You Chose Dog!" << endl;
  24.             PollAmount--;
  25.             DogAmount += "|";
  26.         }
  27.         else if (input == '3') {
  28.             cout << "You Chose Turtle!" << endl;
  29.             PollAmount--;
  30.             TurtleAmount += "|";
  31.         }
  32.         else {
  33.             cout << "Type the correct number" << endl;
  34.         }
  35.         cout << endl;
  36.     } while (PollAmount > 0);
  37.     cout << "THE RESULTS OF THE POLL" << endl;
  38.     cout << "Cat = " << CatAmount << endl;
  39.     cout << "Dog = " << DogAmount << endl;
  40.     cout << "Turtle = " << TurtleAmount << endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement