I want to make a program so that when I type in 1
it will print go ahead
infinite times and like that 2-go left 3-go right. And when I enter 0
it should stop everything and print !!!stop!!!
I have tried many things but I can't even make the 1
command work. Please help.
#include "stdafx.h"
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int value;
cout << "Would you please enter the command " << endl;
cout << " _______________________" << endl;
cout << " 1- go ahead |" << endl;
cout << " _______________________" << endl;
cout << " 2- make a left turn |" << endl;
cout << " _______________________" << endl;
cout << " 3- make a right turn |" << endl;
cout << " _______________________" << endl;
cout << " 4- go back |" << endl;
cout << " _______________________" << endl;
cout << " 0- stop everything |" << endl;
cout << " _____________________________________________________" << endl;
cin >> value;
switch (value)
{
case 1:
while (int value == 1)
{
cout << " * go ahead " << endl;
if (value == 0)
{
break;
}
}
break;
case 2:
cout << " * turn left " << endl;
break;
case 3:
cout << " * turn right " << endl;
break;
case 4:
cout << " * reverse " << endl;
break;
case 0:
cout << " !!!Stop!!! " << endl;
break;
}
return 0;
}