-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05067_QuanLyKhoXangDau.java
75 lines (68 loc) · 2.16 KB
/
J05067_QuanLyKhoXangDau.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
//B21DCCN441
import java.util.*;
import java.math.*;
import java.io.*;
class XangDau {
private String id, maHang, hangSanXuat;
private long donGia, tax, thanhTien, soLuong;
public XangDau(String s) {
this.id = s.split(" ")[0];
this.soLuong = (long) Integer.valueOf(s.split(" ")[1]);
this.maHang = this.id.substring(0, 1);
switch (this.maHang) {
case "X":
this.donGia = 128000;
this.tax = this.donGia * this.soLuong * 3 / 100;
break;
case "D":
this.donGia = 11200;
this.tax = this.donGia * this.soLuong * 35 / 1000;
break;
case "N":
this.donGia = 9700;
this.tax = this.donGia * this.soLuong * 2 / 100;
break;
}
this.hangSanXuat = "";
switch (this.id.substring(3, 5)) {
case "BP":
this.hangSanXuat = "British Petro";
break;
case "ES":
this.hangSanXuat = "Esso";
break;
case "SH":
this.hangSanXuat = "Shell";
break;
case "CA":
this.hangSanXuat = "Castrol";
break;
case "MO":
this.hangSanXuat = "Mobil";
break;
default:
this.hangSanXuat = "Trong Nuoc";
this.tax = 0;
break;
}
this.thanhTien = this.donGia * this.soLuong + this.tax;
}
@Override
public String toString() {
return id + " " + hangSanXuat + " " + donGia + " " + tax + " " + thanhTien;
}
}
public class J05067_QuanLyKhoXangDau {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
ArrayList<XangDau> a = new ArrayList<>();
for (int i = 1; i <= n; i++) {
a.add(new XangDau(sc.nextLine()));
}
for (XangDau xd : a) {
System.out.println(xd);
}
}
}