-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05023.java
51 lines (45 loc) · 1.66 KB
/
J05023.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
import java.util.*;
import java.io.*;
class StudentCourse {
private String studentId;
private String studentName;
private String studentClass;
private String studentEmail;
public StudentCourse(String studentId, String studentName, String studentClass, String studentEmail) {
this.studentId = studentId;
this.studentName = studentName;
this.studentClass = studentClass;
this.studentEmail = studentEmail;
}
public String getStudentClass() {
return studentClass;
}
public String toString() {
return studentId + " " + studentName + " " + studentClass + " " + studentEmail;
}
}
public class J05023 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = Integer.parseInt(sc.nextLine());
ArrayList<StudentCourse> list = new ArrayList<>();
for (int i = 0; i < t; i++) {
String studentId = sc.nextLine();
String studentName = sc.nextLine();
String studentClass = sc.nextLine();
String studentEmail = sc.nextLine();
StudentCourse student = new StudentCourse(studentId, studentName, studentClass, studentEmail);
list.add(student);
}
int n = Integer.parseInt(sc.nextLine());
while (n-- > 0) {
String course = sc.nextLine();
System.out.println("DANH SACH SINH VIEN KHOA " + course + ":");
for (StudentCourse student : list) {
if (student.getStudentClass().substring(1, 3).equals(course.substring(2))) {
System.out.println(student);
}
}
}
}
}