-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartesianPlane.java
More file actions
34 lines (29 loc) · 1.11 KB
/
Copy pathCartesianPlane.java
File metadata and controls
34 lines (29 loc) · 1.11 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
import javax.swing.JOptionPane;
public class CartesianPlane {
public static void main(String[] args) {
int[][] points = new int[5][2];
for (int i = 0; i < 5; i++) {
String input = JOptionPane.showInputDialog("Enter x and y coordinates for point " + (i + 1) + " (e.g., 2,3):");
String[] coordinates = input.split(",");
points[i][0] = Integer.parseInt(coordinates[0].trim());
points[i][1] = Integer.parseInt(coordinates[1].trim());
}
for (int i = 0; i < 5; i++) {
int x = points[i][0];
int y = points[i][1];
String quadrant;
if (x > 0 && y > 0) {
quadrant = "I";
} else if (x < 0 && y > 0) {
quadrant = "II";
} else if (x < 0 && y < 0) {
quadrant = "III";
} else if (x > 0 && y < 0) {
quadrant = "IV";
} else {
quadrant = "Origin";
}
JOptionPane.showMessageDialog(null, "Point (" + x + ", " + y + ") is in Quadrant " + quadrant);
}
}
}