-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist
118 lines (76 loc) · 2.08 KB
/
list
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package listas;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
public class Programa {
public static void main(String[] args) {
Locale.setDefault(Locale.US);
Scanner sc = new Scanner(System.in);
List<Empregados> list = new ArrayList<>();
System.out.println("Quantidade de empregados que deseja cadastrar: ");
int quantEmpregados = sc.nextInt();
for(int i=0; i<quantEmpregados;i++) {
System.out.println();
System.out.print("ID: ");
int id = sc.nextInt();
System.out.print("Nome: ");
sc.nextLine();
String nome = sc.nextLine();
System.out.print("Sálario: ");
double salario = sc.nextDouble();
Empregados empreg = new Empregados(id,nome,salario);
list.add(empreg);
}
System.out.println("Digite o ID do funcionário que ira receber aumento: ");
int idAumento = sc.nextInt();
Empregados empreg = list.stream().filter(x -> x.getId()== idAumento).findFirst().orElse(null);
if(empreg != null) {
System.out.println("Porcentagem a ser adicionada: ");
Double aumentovalor =sc.nextDouble();
empreg.aumentarSalario(aumentovalor);;
}else {
System.out.println("Id Inválido!!");
}
for(Empregados x : list) {
System.out.println(x);
}
sc.close();
}
}
//classe de empregado
package listas;
public class Empregados {
private Integer id;
private String nome;
private Double salario;
public Empregados(Integer id, String nome, Double salario) {
this.id = id;
this.nome = nome;
this.salario = salario;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Double getSalario() {
return salario;
}
public void setSalario(Double salario) {
this.salario = salario;
}
public void aumentarSalario(double aumento) {
this.salario += this.salario * aumento / 100;
}
public String toString() {
return "ID: "+getId()+" Nome: "+ getNome()+" Sálario: " + getSalario();
}
}