-
Notifications
You must be signed in to change notification settings - Fork 1
/
BangLuongTheoPhongBan.java
127 lines (115 loc) · 3.51 KB
/
BangLuongTheoPhongBan.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* 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 PhongBan{
private String id;
private String tenPhong;
public PhongBan(String id, String tenPhong) {
this.id = id;
this.tenPhong = tenPhong;
}
public String getId() {
return id;
}
public String getTenPhong() {
return tenPhong;
}
}
class NhanVien{
private String id;
private String ten;
private String tenPB;
private int luong;
private int soNgay;
public NhanVien(String id, String ten, int luong, int soNgay) {
this.id = id;
this.ten = ten;
this.luong = luong;
this.soNgay = soNgay;
}
public String getId() {
return id;
}
public String getTenPB() {
return tenPB;
}
public void setTenPB(String tenPB) {
this.tenPB = tenPB;
}
public int getLuong(){
char c = this.id.charAt(0);
int idx = Character.valueOf(c) - Character.valueOf('A');
int nam = Integer.parseInt(this.id.substring(1, 3));
int[][] m = {{10, 12, 14, 20},
{10, 11, 13, 16},
{9, 10, 12, 14},
{8, 9, 11, 13}};
if(nam <= 3)
return this.luong * this.soNgay * m[idx][0] * 1000;
else if(nam <= 8)
return this.luong * this.soNgay * m[idx][1] * 1000;
else if(nam <= 15)
return this.luong * this.soNgay * m[idx][2] * 1000;
return this.luong * this.soNgay * m[idx][3] * 1000;
}
@Override
public String toString() {
return this.id + " " + this.ten + " " + this.getLuong();
}
}
public class BangLuongTheoPhongBan {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<PhongBan> p = new ArrayList<>();
ArrayList<NhanVien> a = new ArrayList<>();
sc.nextLine();
for(int i=0; i<n; i++){
String[] s = sc.nextLine().split("\\s+");
String id = s[0];
String tenPhong = "";
for(int j=1; j<s.length; j++){
tenPhong += s[j] + " ";
}
p.add(new PhongBan(id, tenPhong.trim()));
}
int m = sc.nextInt();
for(int i=0; i<m; i++){
sc.nextLine();
String id = sc.nextLine();
String ten = sc.nextLine();
int luong = sc.nextInt();
int soNgay = sc.nextInt();
NhanVien x = new NhanVien(id, ten, luong, soNgay);
for(PhongBan j : p){
if(j.getId().equals(id.substring(3))){
x.setTenPB(j.getTenPhong());
break;
}
}
a.add(x);
}
sc.nextLine();
String pb = sc.nextLine();
String phong = "";
for(PhongBan i : p){
if(i.getId().equals(pb)){
phong = i.getTenPhong();
break;
}
}
System.out.print("Bang luong phong " + phong + ":\n");
for(NhanVien i : a){
if(i.getTenPB().equals(phong)){
System.out.println(i );
}
}
}
}