Quadrants

Write your question here.
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.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  #include <iostream>

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.