Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int menu();
  4. void DoTaskMany(int);
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     bool exit = false;
  11.         for (;;)
  12.         {
  13.             int choice = menu();
  14.             switch(choice)
  15.             {
  16.                 case 1:
  17.                     DoTaskMany(1);
  18.                     break;
  19.                 case 2:
  20.                     DoTaskMany(2);
  21.                     break;
  22.                 case 3:
  23.                     DoTaskMany(3);
  24.                     break;
  25.                 case 4:
  26.                     DoTaskMany(4);
  27.                     break;
  28.                 case 5:
  29.                     continue; // redundant!
  30.                     break;
  31.                 case 6:
  32.                     exit=true;
  33.                     break;
  34.      
  35.                 default:
  36.                     cout << "Please select again! " << endl;
  37.                     break;
  38.             }                    // end switch
  39.      
  40.             if (exit == true)
  41.             break;
  42.     }                        // end forever
  43.     return 0;
  44. }                            // end main()
  45.      
  46. int menu()
  47. {
  48.         int choice;
  49.      
  50.         cout << " **** Menu **** " << endl << endl;
  51.         cout << "(1) 100 o's " << endl;
  52.         cout << "(2) 100 to 200 by twos. " << endl;
  53.         cout << "(3) 200 to 300 by twos. " << endl;
  54.         cout << "(4) 300 to 400 by twos. " << endl;
  55.         cout << "(5) Redisplay menu. " << endl;
  56.         cout << "(6) Quit. " << endl << endl;
  57.         cout << ": ";
  58.         cin >> choice;
  59.         return choice;
  60. }
  61.  
  62.  
  63.  
  64.  
  65. void DoTaskMany(int which)
  66. {
  67.     switch (which)
  68.     {
  69.         case 1:
  70.         {
  71.             int i, j;
  72.             for (i = 1; i<100; i+=2)
  73.             {
  74.                 std::cout << i << " ";
  75.             }
  76.                 std::cout << std::endl;
  77.             break;
  78.         }
  79.     }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement