Guest User

Untitled

a guest
Jan 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include<iostream>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. int value;
  9. cout << "Would you please enter the command " << endl;
  10. cout << " _______________________" << endl;
  11. cout << " 1- go ahead |" << endl;
  12. cout << " _______________________" << endl;
  13. cout << " 2- make a left turn |" << endl;
  14. cout << " _______________________" << endl;
  15. cout << " 3- make a right turn |" << endl;
  16. cout << " _______________________" << endl;
  17. cout << " 4- go back |" << endl;
  18. cout << " _______________________" << endl;
  19. cout << " 0- stop everything |" << endl;
  20. cout << " _____________________________________________________" << endl;
  21.  
  22. cin >> value;
  23.  
  24. switch (value)
  25. {
  26. case '1':
  27. while (int value == 1)
  28. {
  29. cout << " * go ahead " << endl;
  30. if (value == 0)
  31. {
  32. break;
  33. }
  34. }
  35. break;
  36. case '2':
  37. cout << " * turn left " << endl;
  38. break;
  39. case '3':
  40. cout << " * turn right " << endl;
  41. break;
  42. case '4':
  43. cout << " * reverse " << endl;
  44. break;
  45. case '0':
  46. cout << " !!!Stop!!! " << endl;
  47. break;
  48.  
  49. }
  50.  
  51.  
  52. return 0;
  53. }
  54.  
  55. int value = 0;
  56. do{
  57. cin >> value;
  58. switch(value){
  59. case 1:
  60. cout << "go ahead" << endl;
  61. break;
  62. case 2:
  63. cout << "turn left" << endl;
  64. break;
  65. case 3:
  66. cout << "turn right" << endl;
  67. break;
  68. case 4:
  69. cout << "reverse" << endl;
  70. break;
  71. case 0:
  72. cout << "stop" << endl;
  73. break;
  74. }
  75. }while(value!=0);
  76.  
  77. switch (value)
  78. {
  79. case 1:
  80. for (value == 1)
  81. {
  82. cout << " * go ahead " << endl;
  83. if (value == 0)
  84. {
  85. break;
  86. }
  87. }
  88. break;
  89. case 2:
  90. cout << " * turn left " << endl;
  91. break;
  92. case 3:
  93. cout << " * turn right " << endl;
  94. break;
  95. case 4:
  96. cout << " * reverse " << endl;
  97. break;
  98. case 0:
  99. cout << " !!!Stop!!! " << endl;
  100. break;
  101.  
  102. }
Add Comment
Please, Sign In to add comment