-
Notifications
You must be signed in to change notification settings - Fork 1
/
BangKeTienLuong.java
80 lines (74 loc) · 2.38 KB
/
BangKeTienLuong.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
/*
* 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
*/
import java.util.*;
/**
*
* @author Administrator
*/
class NhanVien{
private String id;
private String ten;
private double luong;
private double ngay;
private String chucVu;
public NhanVien(int id, String ten, double luong, double ngay, String chucVu) {
this.id = "NV" + String.format("%02d", id);
this.ten = ten;
this.luong = luong;
this.ngay = ngay;
this.chucVu = chucVu;
}
public double getLuongThang(){
return this.luong * this.ngay;
}
public double getThuong(){
if(this.ngay >= 25)
return this.getLuongThang() * 0.2;
else if(this.ngay >= 22)
return this.getLuongThang() * 0.1;
return 0;
}
public double getPhuCap(){
if(this.chucVu.compareTo("GD") == 0)
return 250000;
else if(this.chucVu.compareTo("PGD") == 0)
return 200000;
else if(this.chucVu.compareTo("TP") == 0)
return 180000;
return 150000;
}
public double getTong(){
return this.getLuongThang() + this.getPhuCap() + this.getThuong();
}
@Override
public String toString() {
return String.format("%s %s %.0f %.0f %.0f %.0f",
this.id, this.ten,
this.getLuongThang(), this.getThuong(), this.getPhuCap(), this.getTong());
}
}
public class BangKeTienLuong {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<NhanVien> a = new ArrayList<>();
sc.nextLine();
for(int i=1; i<=n; i++){
String ten = sc.nextLine();
double luong = sc.nextDouble();
double ngay = sc.nextDouble();
sc.nextLine();
String chucVu = sc.nextLine();
a.add(new NhanVien(i, ten, luong, ngay, chucVu));
}
double sum = 0;
for(NhanVien i : a){
System.out.println(i);
sum += i.getTong();
}
System.out.print("Tong chi phi tien luong: ");
System.out.print(String.format("%.0f", sum));
}
}