File tree Expand file tree Collapse file tree 4 files changed +79
-1
lines changed Expand file tree Collapse file tree 4 files changed +79
-1
lines changed Original file line number Diff line number Diff line change
1
+ import java .time .LocalDate ;
2
+ import java .time .format .DateTimeFormatter ;
3
+ import java .util .Scanner ;
4
+
5
+ import com .example .Cidadao ;
6
+
7
+ public class AppEleitor {
8
+ public static void main (String [] args ) {
9
+ LocalDate dataNascimento ;
10
+ Scanner scanner =new Scanner (System .in );
11
+ System .out .println ("Entre com a data de nascimento do Eleitor: " );
12
+ String strdataNascimento = scanner .nextLine ();
13
+ dataNascimento =LocalDate .parse (strdataNascimento , DateTimeFormatter .ofPattern ("dd/MM/yyyy" ));
14
+ Cidadao cidadao = new Cidadao ();
15
+ cidadao .setDataNascimento (dataNascimento );
16
+ System .out .println (cidadao .getDataNascimento ());
17
+ System .out .println (cidadao .Eleitor ());
18
+ scanner .close ();
19
+
20
+ }
21
+
22
+ }
Original file line number Diff line number Diff line change
1
+ package com .example ;
2
+ public class AppOperadoresRelacionais {
3
+ public static void main (String [] args ) {
4
+ var cliente1 =new Clientes ();
5
+ var cliente2 =new Clientes ();
6
+
7
+ cliente1 .setRenda (12000 );
8
+ cliente2 .setRenda (12000 );
9
+
10
+ if (cliente1 .getRenda ()>cliente2 .getRenda ()) {
11
+ System .out .println ("O cliente 1 tem renda superior ao cliente 2" );
12
+
13
+ }
14
+ else if ((cliente1 .getRenda ()<cliente2 .getRenda ())) {
15
+ System .out .println ("O cliente 1 tem renda inferior ao cliente 2" );
16
+ }
17
+ else {
18
+ System .out .println ("As rendas de ambos os clientes sao iguais." );
19
+ }
20
+
21
+ }
22
+ }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public static void main(String[] args) {
19
19
20
20
21
21
System .out .println (cliente1 .getNome ());
22
- System .out .println (cliente1 .getCpf ());
22
+ System .out .println (cliente1 .getCpf ());
23
23
System .out .println (cliente1 .getRenda ());
24
24
System .out .println (cliente1 .getSexo ());
25
25
System .out .println (cliente1 .getAnoNascimento ());
Original file line number Diff line number Diff line change
1
+ package com .example ;
2
+
3
+ import java .time .LocalDate ;
4
+
5
+
6
+ public class Cidadao {
7
+ private LocalDate dataNascimento ;
8
+
9
+ public LocalDate getDataNascimento () {
10
+ return dataNascimento ;
11
+ }
12
+
13
+ public void setDataNascimento (LocalDate dataNascimento ) {
14
+ this .dataNascimento = dataNascimento ;
15
+ }
16
+ public int Idade () {
17
+ return LocalDate .now ().getYear () - getDataNascimento ().getYear ();
18
+ }
19
+ public String Eleitor () {
20
+ int idade = Idade ();
21
+
22
+ if (idade <16 ) {
23
+ return "Nao eh Eleitor ....!" ;
24
+ }
25
+ else if ((idade >=16 && idade < 18 )||(idade >70 )) {
26
+ return "Eleitor facultativo....!" ;
27
+ }
28
+ else {
29
+ return "Eleitor obrigatorio ....!" ;
30
+ }
31
+
32
+ }
33
+ }
34
+
You can’t perform that action at this time.
0 commit comments