Sinux1

PS5Q8 cs 111

Mar 11th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int choice;
  7. do
  8. {
  9.  
  10.  
  11.     string direction;
  12.  
  13.  
  14.     cout << "Which direction would you like to move?\n",
  15.     cout << "[8] North\n",
  16.     cout << "[4] West\n",
  17.     cout << "[2] South\n",
  18.     cout << "[6] East\n",
  19.     cout << "[0] Exit\n";
  20.     cin >> choice;
  21.  
  22.     if (choice >= 2 && choice <= 8 && choice % 2 == 0)
  23.     {
  24.        if (choice == 8)
  25.         direction = "north";
  26.         else if (choice == 4)
  27.         direction = "west";
  28.         else if (choice == 2)
  29.         direction = "south";
  30.         else if (choice == 6)
  31.         direction = "east";
  32.  
  33.         cout << "You moved " << direction << "." << endl;
  34.     }
  35.  
  36.  
  37.  
  38.  
  39.  
  40. } while (choice != 0);
  41.  
  42.  
  43.     return 0;
  44. }
Add Comment
Please, Sign In to add comment