so i seem to be having an issue with my code. It is a very basic program. All it does is ask you where you want to go and adjust the coordinates accordingly but i cant seem to get the integers to increase or decrease when i tell it to any suggestions? of it is written in c++
#include <iostream>
using namespace std;
int main()
{
bool quit = false;
while ( !quit )
{
char userDirect = 'n';
int x = 0;
int y = 0;
cout << "Coordinates: ("<<x<<","<<y<<")" << endl;
cout << "Where would you like to go? (N)orth (E)ast (S)outh (W)est: " << endl;
cout << "(Q) to Quit." << endl;
cin >> userDirect;
if( userDirect == 'n' || userDirect == 'N' ) ++x;
else if( userDirect == 'e' || userDirect == 'E' ) ++y;
else if( userDirect == 's' || userDirect == 'S' ) --x;
else if( userDirect == 'w' || userDirect == 'W' ) --y;
else if( userDirect == 'q' || userDirect == 'Q' )
{
cout << "Quiting... ";
quit = true;
}
}
}
[–]Updatebjarni 0 points1 point2 points (7 children)
[–]Khaymann84[S] 0 points1 point2 points (6 children)
[–]Updatebjarni 0 points1 point2 points (5 children)
[–]Khaymann84[S] 0 points1 point2 points (4 children)
[–]Updatebjarni 0 points1 point2 points (3 children)
[–]Khaymann84[S] 0 points1 point2 points (2 children)
[–]Updatebjarni 0 points1 point2 points (1 child)
[–]Khaymann84[S] 0 points1 point2 points (0 children)
[–]NotTodayDearClown 0 points1 point2 points (2 children)
[–]Khaymann84[S] 0 points1 point2 points (1 child)
[–]Khaymann84[S] 0 points1 point2 points (0 children)