-
Notifications
You must be signed in to change notification settings - Fork 1
/
BangDiemHocSinh.java
90 lines (83 loc) · 2.72 KB
/
BangDiemHocSinh.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
82
83
84
85
86
87
88
89
90
/*
* 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 HocSinh implements Comparable<HocSinh>{
private String id;
private String ten;
private double toan, tv, ngoai, ly, hoa, sinh, su, dia, gdcd, cn;
public HocSinh(int id, String ten, double toan, double tv, double ngoai, double ly, double hoa, double sinh, double su, double dia, double gdcd, double cn) {
this.id = "HS" + String.format("%02d", id);
this.ten = ten;
this.toan = toan;
this.tv = tv;
this.ngoai = ngoai;
this.ly = ly;
this.hoa = hoa;
this.sinh = sinh;
this.su = su;
this.dia = dia;
this.gdcd = gdcd;
this.cn = cn;
}
public double getDiem(){
return ((this.toan + this.tv)*2.0 + this.ngoai + this.ly + this.hoa +
this.sinh + this.su + this.dia + this.gdcd + this.cn)/12.0;
}
public String getHK(){
double d = this.getDiem();
if(d >= 9.0)
return "XUAT SAC";
else if(d >= 8.0)
return "GIOI";
else if(d >= 7.0)
return "KHA";
else if(d >= 5.0)
return "TB";
else
return "YEU";
}
@Override
public int compareTo(HocSinh b){
if(this.getDiem() != b.getDiem())
return -Double.compare(this.getDiem(), b.getDiem());
return this.id.compareTo(b.id);
}
@Override
public String toString() {
return this.id + " " + this.ten + " " + String.format("%.1f", Math.round(this.getDiem() *10.f)/10.f) + " " + this.getHK();
}
}
public class BangDiemHocSinh {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<HocSinh> a = new ArrayList<>();
for(int i=1; i<=n; i++){
sc.nextLine();
String ten = sc.nextLine();
double toan = sc.nextDouble();
double tv = sc.nextDouble();
double ngoai = sc.nextDouble();
double ly = sc.nextDouble();
double hoa = sc.nextDouble();
double sinh = sc.nextDouble();
double su = sc.nextDouble();
double dia = sc.nextDouble();
double gdcd = sc.nextDouble();
double cn = sc.nextDouble();
a.add(new HocSinh(i, ten, toan, tv, ngoai, ly, hoa, sinh, su, dia, gdcd, cn));
}
Collections.sort(a);
for(HocSinh i : a){
System.out.println(i);
}
}
}