Advertisement
avr39ripe

simpeMenuTemplate

Oct 8th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     char action{ 'x' };
  6.  
  7.     do
  8.     {
  9.         std::cout << "Action 1 - a\n";
  10.         std::cout << "Action 2 - b\n";
  11.         std::cout << "Action 3 - c\n";
  12.         std::cout << "Exit - x\n";
  13.  
  14.         std::cout << "Enter a,b,c to select action\nEnter x to exit\n";
  15.        
  16.         std::cin >> action;
  17.  
  18.  
  19.         switch (action)
  20.         {
  21.         case 'a':
  22.             std::cout << "User select Action 1\n";
  23.             std::cout << "Boom!\n";
  24.             break;
  25.         case 'b':
  26.             std::cout << "User select Action 2\n";
  27.             std::cout << "OOps!!\n";
  28.             break;
  29.         case 'c':
  30.             std::cout << "User select Action 3\n";
  31.             std::cout << "Nothing :(\n";
  32.             break;
  33.         case 'x':
  34.             break;
  35.         default:
  36.             std::cout << "Incorrect selection! Try again!\n";
  37.         }
  38.     } while (action != 'x');
  39.    
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement