-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05074_DiemDanh1.java
67 lines (59 loc) · 1.73 KB
/
J05074_DiemDanh1.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
66
67
//B21DCCN441
import java.util.*;
import java.math.*;
import java.io.*;
class sinhVien {
public String id, name, lop;
public int chuyenCan;
public sinhVien(String id, String name, String lop) {
this.id = id;
this.name = name;
this.lop = lop;
}
public void setDiemChuyenCan(String s) {
int score = 10;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'x') {
continue;
} else if (s.charAt(i) == 'v') {
score -= 2;
} else {
score -= 1;
}
}
this.chuyenCan = score > 0 ? score : 0;
}
@Override
public String toString() {
String ans = this.id + " " + this.name + " " + this.lop + " " + this.chuyenCan;
if (this.chuyenCan == 0) {
ans += " KDDK";
}
return ans;
}
}
public class J05074_DiemDanh1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
ArrayList<sinhVien> a = new ArrayList<>();
for (int i = 1; i <= n; i++) {
a.add(new sinhVien(sc.nextLine(), sc.nextLine(), sc.nextLine()));
}
for (int i = 1; i <= n; i++) {
String s = sc.nextLine();
String id = s.split(" ")[0];
String trangThai = s.split(" ")[1];
for (sinhVien sV : a) {
if (sV.id.equals(id)) {
sV.setDiemChuyenCan(trangThai);
break;
}
}
}
for (sinhVien sV : a) {
System.out.println(sV);
}
}
}