-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartesianCoordinates.cpp
More file actions
117 lines (109 loc) · 2.46 KB
/
CartesianCoordinates.cpp
File metadata and controls
117 lines (109 loc) · 2.46 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream> // To use cin/cout
using namespace std;
int main()
{
int x, y; // Initialize integers
cout << "Cartesian Coordinate Identifier Program" << endl
<< "By Forrest Moulin" << endl << endl
<< "Please enter x and y values separated by a space:" << endl
<< "Example: 100 200" << endl << endl;
// Get user input
cin >> x >> y;
cout << endl << "You entered (" << x << ", " << y << ")." << endl;
// 1st quadrant (+x, +y)
if (x > 0 && y > 0)
{
cout << "Your point is located in the First Quadrant " <<
"(+x, +y)." << endl;
}
// 2nd quadrant (-x, +y)
else if (x < 0 && y > 0)
{
cout << "Your point is located in the Second Quadrant " <<
"(-x, +y)." << endl;
}
// 3rd quadrant (-x, -y)
else if (x < 0 && y < 0)
{
cout << "Your point is located in the Third Quadrant " <<
"(-x, -y)." << endl;
}
// 4th quadrant (+x, -y)
else if (x > 0 && y < 0)
{
cout << "Your point is located in the Fourth Quadrant " <<
"(+x, -y)." << endl;
}
// X-axis (x = 0)
else if (x == 0 && y != 0)
{
cout << "Your point is located on the x-axis (x = 0)." << endl;
}
// Y-axis (y = 0)
else if (x != 0 && y == 0)
{
cout << "Your point is located on the y-axis (y = 0)." << endl;
}
// Origin (0,0)
else if (x == 0 && y == 0)
{
cout << "Your point is located on the origin (0,0)." << endl;
}
// Error message if any other invalid values entered.
else
{
cout << "Please enter valid x and y values, and try again." << endl;
}
}
/*
* CONSOLE OUTPUT # 1 - Y-AXIS
* Cartesian Coordinate Identifier Program
* By Forrest Moulin
*
* Please enter x and y values separated by a space:
* Example: 100 200
*
* 100 0
*
* You entered (100, 0).
* Your point is located on the y-axis (y = 0).
*/
/*
* CONSOLE OUTPUT # 2 - X-AXIS
* Cartesian Coordinate Identifier Program
* By Forrest Moulin
*
* Please enter x and y values separated by a space:
* Example: 100 200
*
* 0 2000
*
* You entered (0, 2000).
* Your point is located on the x-axis (x = 0).
*/
/*
* CONSOLE OUTPUT # 3 - ORIGIN
* Cartesian Coordinate Identifier Program
* By Forrest Moulin
*
* Please enter x and y values separated by a space:
* Example: 100 200
*
* 0 0
*
* You entered (0, 0).
* Your point is located on the origin (0,0).
*/
/*
* CONSOLE OUTPUT # 4 - 1ST QUADRANT
* Cartesian Coordinate Identifier Program
* By Forrest Moulin
*
* Please enter x and y values separated by a space:
* Example: 100 200
*
* 15 10
*
* You entered (15, 10).
* Your point is located in the First Quadrant (+x, +y).
*/