1import java.util.*;
2
3enum Department { ENGINEERING, ADMISSIONS, MARKETING, ACADEMICS }
4
5class Employee {
6 private final int id;
7 private final String name;
8 private final Department department;
9 private final double baseSalary;
10 private double performanceScore; // 1.0 to 5.0
11
12 public Employee(int id, String name, Department dept, double salary, double score) {
13 this.id = id;
14 this.name = name;
15 this.department = dept;
16 this.baseSalary = salary;
17 this.performanceScore = score;
18 }
19
20 public double calculateNetSalary() {
21 // Performance bonus: 10% for scores >= 4.5; 5% for scores >= 3.5
22 double bonusMultiplier = (performanceScore >= 4.5) ? 0.10 : (performanceScore >= 3.5 ? 0.05 : 0.0);
23 return baseSalary + (baseSalary * bonusMultiplier);
24 }
25
26 public int getId() { return id; }
27 public String getName() { return name; }
28 public double getScore() { return performanceScore; }
29 public Department getDepartment() { return department; }
30}
31
32public class PayrollTerminal {
33 public static void main(String[] args) {
34 List<Employee> staff = new ArrayList<>(List.of(
35 new Employee(101, "Deepak Yadav", Department.ENGINEERING, 75000.0, 4.8),
36 new Employee(102, "Sneha Gupta", Department.ACADEMICS, 65000.0, 4.2),
37 new Employee(103, "Aarav Sharma", Department.ADMISSIONS, 50000.0, 3.2),
38 new Employee(104, "Rohan Verma", Department.MARKETING, 58000.0, 4.6)
39 ));
40
41 // Sort by Highest Performance Score using Comparator:
42 staff.sort(Comparator.comparingDouble(Employee::getScore).reversed());
43
44 System.out.println("=========================================================================");
45 System.out.println(" MSK INSTITUTE MONTHLY PAYROLL REPORT ");
46 System.out.println("=========================================================================");
47 System.out.printf("%-6s %-18s %-15s %-8s %15s%n", "ID", "Name", "Department", "Rating", "Net Salary (₹)");
48 System.out.println("-------------------------------------------------------------------------");
49
50 double totalDisbursed = 0.0;
51 for (Employee e : staff) {
52 double net = e.calculateNetSalary();
53 totalDisbursed += net;
54 System.out.printf("%-6d %-18s %-15s %-8.1f ₹%14,.2f%n",
55 e.getId(), e.getName(), e.getDepartment(), e.getScore(), net);
56 }
57
58 System.out.println("=========================================================================");
59 System.out.printf("Total Monthly Payroll Disbursed: ₹%,.2f%n", totalDisbursed);
60 System.out.println("=========================================================================");
61 }
62}