-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDesafio.java
More file actions
100 lines (87 loc) · 2.58 KB
/
Desafio.java
File metadata and controls
100 lines (87 loc) · 2.58 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
package Class1;
import java.util.Scanner;
public class Desafio {
public static void main(String[] args) {
try {
Scanner input = new Scanner(System.in);
char resposta;
int cont = 0;
menu();
System.out.println("Telefonou para vítima? ");
resposta = input.next().charAt(0);
while(!(resposta == '1' || resposta == '2')) {
System.out.println("Resposta invalida! Tente novamente.");
menu();
System.out.println("Telefonou para vítima? ");
resposta = input.next().charAt(0);
}
if(resposta == '1'){
cont++;
}
menu();
System.out.println("Esteve no local do crime? ");
resposta = input.next().charAt(0);
while(!(resposta == '1' || resposta == '2')) {
System.out.println("Resposta invalida! Tente novamente.");
menu();
System.out.println("Esteve no local do crime? ");
resposta = input.next().charAt(0);
}
if(resposta == '1'){
cont++;
}
menu();
System.out.println("Mora perto da vítima? ");
resposta = input.next().charAt(0);
while(!(resposta == '1' || resposta == '2')) {
System.out.println("Resposta invalida! Tente novamente.");
menu();
System.out.println("Mora perto da vítima? ");
resposta = input.next().charAt(0);
}
if(resposta == '1'){
cont++;
}
menu();
System.out.println("Devia para vítima? ");
resposta = input.next().charAt(0);
while(!(resposta == '1' || resposta == '2')) {
System.out.println("Resposta invalida! Tente novamente.");
menu();
System.out.println("Devia para vítima? ");
resposta = input.next().charAt(0);
}
if(resposta == '1'){
cont++;
}
menu();
System.out.println("Já trabalhou com a vítima? ");
resposta = input.next().charAt(0);
while(!(resposta == '1' || resposta == '2')) {
System.out.println("Resposta invalida! Tente novamente.");
menu();
System.out.println("Já trabalhou com a vítima? ");
resposta = input.next().charAt(0);
}
if(resposta == '1'){
cont++;
}
if(cont == 2) {
System.out.println("Suspeita");
}else if(cont > 2 && cont <= 4) {
System.out.println("Cúmplice");
}else if(cont > 4){
System.out.println("Assassino(a)");
}else {
System.out.println("Inocente");
}
} catch (Exception ex) {
System.out.println("Error em alguma parte do código: "+ex.getMessage());
}
}
public static void menu(){
System.out.println("Responda: ");
System.out.println("[1] Sim");
System.out.println("[2] Não");
}
}