forked from alkokt/PP2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuadran.java
More file actions
67 lines (65 loc) · 2.27 KB
/
Quadran.java
File metadata and controls
67 lines (65 loc) · 2.27 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
import java.util.Scanner;
public class Quadran {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
String hasil = "";
if ( x < 0 && y > 0){
if (x + y < 0) {
hasil = "Q1";
}
else if (x + y > 0) {
hasil = "Q2";
}
else {
hasil = "garis Q1 dan Q2";
}
}
if (x > 0 && y > 0) {
if (x < y) {
hasil = "Q3";
}
else if (x > y) {
hasil = "Q4";
}
else {
hasil = "garis Q3 dan Q4";
}
}
if (x > 0 && y < 0) {
if (x + y > 0) {
hasil = "Q5";
}
else if (x + y < 0) {
hasil = "Q6";
}
else {
hasil = "garis Q5 dan Q6";
}
}
if (x < 0 && y < 0){
if (x > y) {
hasil = "Q7";
}
else if (x > y) {
hasil = "Q8";
}
else {
hasil = "garis Q7 dan Q8";
}
}
if (x == 0 && y > 0) {
hasil = "garis Q2 dan Q3";
} else if (y == 0 && y > 0) {
hasil = "garis Q4 dan Q5";
} else if (x == 0 && y < 0) {
hasil = "garis Q6 dan Q7";
} else if (y == 0 && x < 0) {
hasil = "garis Q8 dan Q1";
} else if (y == 0 && x == 0) {
hasil = "titik pusat";
}
System.out.print("Titik ("+x+"," +y+ ") berada pada " + hasil);
}
}