-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBaiToanTuyenSinh.java
66 lines (59 loc) · 1.97 KB
/
BaiToanTuyenSinh.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
/*
* 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.*;
/**
*
* @author Administrator
*/
class ThiSinh{
private String maThiSinh;
private String hoten;
private double diemToan;
private double diemLy;
private double diemHoa;
public ThiSinh(String maThiSinh, String hoten, double diemToan, double diemLy, double diemHoa) {
this.maThiSinh = maThiSinh;
this.hoten = hoten;
this.diemToan = diemToan;
this.diemLy = diemLy;
this.diemHoa = diemHoa;
}
public double getUuTien(){
String s = this.maThiSinh.substring(0, 3);
if(s.compareTo("KV1") == 0)
return 0.5;
if(s.compareTo("KV2") == 0)
return 1.0;
return 2.5;
}
public double getDiem(){
return this.diemToan*2 + this.diemLy + this.diemHoa;
}
public String getKetQua(){
if(getDiem() + getUuTien() < 24.0)
return "TRUOT";
return "TRUNG TUYEN";
}
@Override
public String toString() {
return this.maThiSinh + " " + this.hoten + " " +
((int)getUuTien() == getUuTien() ? String.format("%d", (int)getUuTien()) : String.format("%.1f", getUuTien())) + " " +
((int)getDiem() == getDiem() ? String.format("%d", (int)getDiem()) : String.format("%.1f", getDiem())) + " " +
getKetQua();
}
}
public class BaiToanTuyenSinh {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String maThiSinh = sc.nextLine();
String hoTen = sc.nextLine();
double diemToan = sc.nextDouble();
double diemLy = sc.nextDouble();
double diemHoa = sc.nextDouble();
ThiSinh a = new ThiSinh(maThiSinh, hoTen, diemToan, diemLy, diemHoa);
System.out.println(a);
}
}