-
Notifications
You must be signed in to change notification settings - Fork 1
/
LietKeSinhVienTheoKhoa.java
65 lines (59 loc) · 1.67 KB
/
LietKeSinhVienTheoKhoa.java
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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package codeptit;
import java.util.*;
import java.math.*;
/**
*
* @author Administrator
*/
class SinhVien{
private String id;
private String ten;
private String lop;
private String mail;
public SinhVien(String id, String ten, String lop, String mail) {
this.id = id;
this.ten = ten;
this.lop = lop;
this.mail = mail;
}
public String getId() {
return id;
}
public String getLop() {
return lop;
}
@Override
public String toString() {
return this.id + " " + this.ten + " " + this.lop + " " + this.mail;
}
}
public class LietKeSinhVienTheoKhoa {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<SinhVien> a = new ArrayList<>();
sc.nextLine();
for(int i=0; i<n; i++){
String id = sc.nextLine();
String ten = sc.nextLine();
String lop = sc.nextLine();
String mail = sc.nextLine();
a.add(new SinhVien(id, ten, lop, mail));
}
int t = sc.nextInt();
sc.nextLine();
while(t-- > 0){
String s = sc.nextLine();
System.out.println("DANH SACH SINH VIEN KHOA " + s + ":");
String cmp = s.substring(2);
for(SinhVien i : a){
if(i.getLop().substring(1, 3).equals(cmp))
System.out.println(i);
}
}
}
}