Advertisement
aprsc7

If else

Nov 17th, 2019 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     char option, askExit;
  7.     float startPos, speed;
  8.  
  9.     do
  10.     {
  11.         system("cls");
  12.         cout << "Type of robot (B - biped, H - hexapod, T - two-wheeled): ";
  13.  
  14.         while(1)
  15.         {
  16.             cin >> option;
  17.             if(option=='b'||option=='B')
  18.             {
  19.                 speed = 0.15;
  20.                 break;
  21.             }
  22.  
  23.             else if(option=='h'||option=='H')
  24.             {
  25.                 speed = 0.07;
  26.                 break;
  27.             }
  28.  
  29.             else if(option=='t'||option=='T')
  30.             {
  31.                 speed = 0.45;
  32.                 break;
  33.             }
  34.  
  35.             else
  36.                 cout << "Type of robot again (B - biped, H - hexapod, T - two-wheeled: ";
  37.         }
  38.  
  39.         cout << "Initial position of the robot (m): ";
  40.         cin >> startPos;
  41.  
  42.         cout << "\nPosition of robot in 10 sec:\n";
  43.         cout << "Time (s)\tPostion (m)\n";
  44.  
  45.         for(int i=1;i<=10;i++)
  46.             cout << i << "\t\t" << startPos + speed*i << "\n";
  47.  
  48.  
  49.         cout << "\nRepeat the whole process? (Y/N): ";
  50.         cin >> askExit;
  51.  
  52.     } while (askExit=='y'||askExit=='Y');
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement