Can anyone give me some suggestions on how I could edit the below code to output to the user which quadrant they are in (Northeast, Southeast, Southwest, Northwest) If they are on an axis, simply state that they are (North, South, East, or West). Example: If the user moves so that coordinates are (1,3), they are in the Northeast quadrant.

Thank you

I want to use for example a if (x > 0 && y > 0) then quadrant = "Northeast" but I cannot figure out the syntax to make that work in my below code.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556`` `````` #include using namespace std; int main() { bool compass = true; int x = 0; int y = 0; cout << "enter direction: N (north), E (east), S (south), W (west) or Q to pause: (" << x << "," << y << ")"; char direction; cin >> direction; do{ if(direction == 'E'||direction == 'e'){ x += 1; cout << "enter direction: N (north), E (east), S (south), W (west) or Q to pause: (" << x << "," << y << ")"; cin >> direction; } else if(direction == 'S'||direction == 's'){ y -= 1; cout << "enter direction: N (north), E (east), S (south), W (west) or Q to pause:(" << x << "," << y << ")"; cin >> direction; } else if(direction == 'N'||direction == 'n'){ y += 1; cout << "enter direction: N (north), E (east), S (south), W (west) or Q to pause:(" << x << "," << y << ")"; cin >> direction; } else if(direction == 'W'||direction == 'w'){ x -= 1; cout << "enter direction: N (north), E (east), S (south), W (west) or Q to pause:(" << x << "," << y << ")"; cin >> direction; } else if (direction == 'q' || direction == 'Q') system ("pause"); }while(compass == true); return 0; }``````
Last edited on
Topic archived. No new replies allowed.