MasterZii

working_repeat_1-100

Aug 12th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6.     int hun;
  7.     std::string answer;
  8.     bool repeat = true;
  9.     while (repeat == true)
  10.     {
  11.         std::cout << "Please pick a number between 1 and 100 \n";
  12.         std::cin >> hun;
  13.         if (hun > 50 && hun <= 100)
  14.         {
  15.             std::cout << "Your number is greater than 50. ";
  16.         }
  17.         else if (hun < 50)
  18.         {
  19.             std::cout << "Your number is less than 50. ";
  20.         }
  21.         else if (hun == 50)
  22.         {
  23.             std::cout << "Your number is equal to 50. ";
  24.         }
  25.         else
  26.         {
  27.             std::cout << "Pick a number less than 100. ";
  28.         }
  29.  
  30.         std::cout << "Want to try again? ";
  31.         std::cin >> answer;
  32.         if (answer == "Yes" || answer == "yes")
  33.         {
  34.             repeat = true;
  35.         }
  36.         else if (answer == "No" || answer == "no")
  37.         {
  38.             repeat = false;
  39.         }
  40.     }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment