-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05013_TuyenDung.java
61 lines (55 loc) · 1.64 KB
/
J05013_TuyenDung.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
//B21DCCN441
import java.util.*;
import java.math.*;
import java.io.*;
class ThiSinh {
public String id, name, trangThai;
public float lt, th, tb;
public ThiSinh(int i, String name, float lyThuyet, float thucHanh) {
this.id = "TS" + i;
if (i < 10) {
this.id = "TS0" + i;
}
this.name = name;
if (lyThuyet > 10) {
lyThuyet /= 10;
}
if (thucHanh > 10) {
thucHanh /= 10;
}
this.lt = lyThuyet;
this.th = thucHanh;
this.tb = (this.lt + this.th) / 2;
this.trangThai = "TRUOT";
if (this.tb > 9.5) {
this.trangThai = "XUAT SAC";
} else if (this.tb >= 8) {
this.trangThai = "DAT";
} else if (this.tb >= 5) {
this.trangThai = "CAN NHAC";
}
}
public void display() {
System.out.printf("%s %s %.2f %s\n", this.id, this.name, this.tb, this.trangThai);
}
}
public class J05013_TuyenDung {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<ThiSinh> a = new ArrayList<>();
for (int i = 1; i <= n; i++) {
sc.nextLine();
a.add(new ThiSinh(i, sc.nextLine(), sc.nextFloat(), sc.nextFloat()));
}
Collections.sort(a, new Comparator<ThiSinh>() {
@Override
public int compare(ThiSinh t, ThiSinh t1) {
return t.tb > t1.tb ? -1 : 1;
}
});
for (ThiSinh ts : a) {
ts.display();
}
}
}