-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path60.java
More file actions
51 lines (44 loc) · 1.1 KB
/
60.java
File metadata and controls
51 lines (44 loc) · 1.1 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
/*******************************************************************************
* 60) Escreva um programa que retorne o número do quadrante (1,2,3 ou 4) através
* de um método chamado VERIFICA_QUADRANTE, que deve receber um valor para x e um
* valor para y.
Quadrantes
* x |
* |
* 2o | 1o
* |
*y ----------------------
* |
* |
* 3o | 4o
* |
*******************************************************************************/
import java.util.Scanner;
import java.util.Arrays;
public class Exercicio {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int x,y;
x=entrada.nextInt();
y=entrada.nextInt();
System.out.print(VerificaQuadrante(x,y));
}
public static int VerificaQuadrante(int x, int y){
boolean quadx,quady;
if(x>=0){
quadx=true;
}else{
quadx=false;
}
if(y>=0){
quady=true;
}else{
quady=false;
}
if(x==0||y==0) return 0;
else if(quadx&&quady) return 1;
else if (!quadx&&quady) return 2;
else if (!quadx&&!quady) return 3;
else return 4;
}
}