-
Notifications
You must be signed in to change notification settings - Fork 1
/
KetQuaXetTuyen.java
81 lines (73 loc) · 2.35 KB
/
KetQuaXetTuyen.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* 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 NewNhanVien;
import java.util.*;
/**
*
* @author Administrator
*/
class Nguoi{
private String id;
private String ten;
private String dob;
private double diemLT;
private double diemTH;
public Nguoi(int id, String ten, String dob, double diemLT, double diemTH) {
this.id = "PH" + String.format("%02d", id);
this.ten = ten;
this.dob = dob;
this.diemLT = diemLT;
this.diemTH = diemTH;
}
public int getTuoi(){
return 2021 - Integer.parseInt(this.dob.substring(this.dob.lastIndexOf("/")+1));
}
public double getDiemThuong(){
if(this.diemLT >= 8 && this.diemTH >= 8)
return 1;
else if(this.diemLT >= 7.5 && this.diemTH >= 7.5)
return 0.5;
return 0;
}
public int getDiemTB(){
if((this.diemLT + this.diemTH)/2.0 + this.getDiemThuong() >= 10)
return 10;
return (int)Math.round((this.diemLT + this.diemTH)/2.0 + this.getDiemThuong());
}
public String getXepLoai(){
if(this.getDiemTB() < 5)
return "Truot";
else if(this.getDiemTB() <= 6)
return "Trung binh";
else if(this.getDiemTB() == 7)
return "Kha";
else if(this.getDiemTB() == 8)
return "Gioi";
return "Xuat sac";
}
@Override
public String toString() {
return this.id + " " + this.ten + " " + this.getTuoi() + " " + this.getDiemTB()
+ " " + this.getXepLoai();
}
}
public class KetQuaXetTuyen {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<Nguoi> a = new ArrayList<>();
for(int i=1; i<=n; i++){
sc.nextLine();
String ten = sc.nextLine();
String dob = sc.nextLine();
double diemLT = sc.nextDouble();
double diemTH = sc.nextDouble();
a.add(new Nguoi(i, ten, dob, diemLT, diemTH));
}
for(Nguoi i : a){
System.out.println(i);
}
}
}