New paste Repaste Download
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        ArrayList<Employee> employees = new ArrayList<>();
        
        int l = sc.nextInt();sc.nextLine();
        for(int i = 0; i < l; i++){
            ArrayList<Project> projects = new ArrayList<>();
            int eid = sc.nextInt();sc.nextLine();
            String en = sc.nextLine();
            String cn = sc.nextLine();
            int pc = sc.nextInt();sc.nextLine();
            for(int j = 0; j < pc; j++){
                String pn = sc.nextLine();
                int r = sc.nextInt();sc.nextLine();
                projects.add(new Project(pn, r));
            }
            employees.add(new Employee(eid, en, cn, pc, projects));
            
        }
        int empId = sc.nextInt();sc.nextLine();
        int threshold = sc.nextInt();
        sc.close();
        
        HashSet<Integer> uniqueRating = uniqueRating(employees, empId);
        if(uniqueRating.size() == 0){
            System.out.println("No Employee Found");
        }
        else{
            for (Integer i : uniqueRating) {
                System.out.println(i);
            }
        }
        ArrayList<String> empRating = averageRatingOfEmployee(employees, threshold);
        if(empRating.size() == 0){
            System.out.println("No Employee Found");
        }
        else{
            for (String s : empRating) {
                System.out.println(s);
            }
        }
        
    }
    
    public static HashSet<Integer> uniqueRating(ArrayList<Employee> employees, int Id){
        HashSet<Integer> rating = new HashSet<>();
        for (Employee employee : employees) {
            if(employee.empId == Id){
                for (Project project : employee.projects) {
                    rating.add(project.rating);
                }
                break;
            }
        }
        return rating;
    }
    
    public static ArrayList<String> averageRatingOfEmployee(ArrayList<Employee> employees, int threshold){
        
        ArrayList<String> empName = new ArrayList<>();
        for (Employee employee : employees) {
        int sum = 0;
        int count = 0;
        double avg = 0;
            for (Project project : employee.projects) {
                sum += project.rating;
                count++;
            }
            avg = sum / count;
            if(avg > threshold){
                empName.add(employee.eName);
            }
        }
        return empName;
    }
}
class Employee{
    int empId;
    String eName;
    String cName;
    int projectCount;
    ArrayList<Project> projects;
    public Employee(int eid, String en, String cn, int pc, ArrayList<Project> p){
        this.empId = eid;
        this.eName = en;
        this.cName = cn;
        this.projectCount = pc;
        this.projects = p;
    }
}
class Project{
    String pName;
    int rating;
    public Project(String pn, int r){
        this.pName = pn;
        this.rating = r;
    }
}
Filename: None. Size: 3kb. View raw, , hex, or download this file.

This paste expires on 2024-11-21 04:55:43.115613. Pasted through web.