-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ05027.java
More file actions
61 lines (51 loc) · 1.58 KB
/
J05027.java
File metadata and controls
61 lines (51 loc) · 1.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
import java.util.*;
class GiangVien {
private String ma, ten, khoa;
public GiangVien(int ma, String ten, String khoa) {
this.ma = "GV" + String.format("%02d", ma);
this.ten = ten;
this.khoa = khoa;
}
public String getMa() {
return ma;
}
public String getTen() {
return ten;
}
public String getKhoa() {
return khoa;
}
public String toString() {
return this.ma + " " + this.ten + " " + this.khoa;
}
}
public class J05027 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
ArrayList<GiangVien> a = new ArrayList<>();
for (int i = 1; i <= t; i++) {
String ten = sc.nextLine();
String khoa = sc.nextLine();
StringBuilder sb = new StringBuilder("");
String[] tmp = khoa.split("\\s+");
for (String y : tmp) {
sb.append(y.toUpperCase().charAt(0));
}
GiangVien x = new GiangVien(i, ten, sb.toString());
a.add(x);
}
int q = sc.nextInt();
sc.nextLine();
while (q-- > 0) {
String test = sc.nextLine();
System.out.println("DANH SACH GIANG VIEN THEO TU KHOA " + test + ":");
for (GiangVien x : a) {
if (x.getTen().toUpperCase().contains(test.toUpperCase())) {
System.out.println(x);
}
}
}
}
}