-
Notifications
You must be signed in to change notification settings - Fork 1
/
Example 10.java
40 lines (34 loc) · 1.36 KB
/
Example 10.java
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
import java.util.Scanner;
public class QuadrantFinder {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Prompt user to enter the coordinates
System.out.print("Enter the x-coordinate: ");
double x = scanner.nextDouble();
System.out.print("Enter the y-coordinate: ");
double y = scanner.nextDouble();
// Determine the quadrant
if (x > 0 && y > 0)
{
System.out.println("The point (" + x + ", " + y + ") is in the First Quadrant.");
}
else if (x < 0 && y > 0){
System.out.println("The point (" + x + ", " + y + ") is in the Second Quadrant.");
}
else if (x < 0 && y < 0) {
System.out.println("The point (" + x + ", " + y + ") is in the Third Quadrant.");
}
else if (x > 0 && y < 0) {
System.out.println("The point (" + x + ", " + y + ") is in the Fourth Quadrant.");
}
else if (x == 0 && y != 0) {
System.out.println("The point (" + x + ", " + y + ") is on the y-axis.");
}
else if (x != 0 && y == 0) {
System.out.println("The point (" + x + ", " + y + ") is on the x-axis.");
}
else {
System.out.println("The point (" + x + ", " + y + ") is at the origin.");
}
}
}