Employee Implementation Online Assessment Hackerrank - How to solve?
Anonymous User
8383

I have been working on this problem but couldn't able to understand it properly. Can anyone explain me how should we approach? Thank you and appreciate your help.

image

image



import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

interface Company {
void assignSalaries(int[] salaries);
void averageSalary();
void maxSalary();
void minSalary();
}

/* model output for cut and paste
Incomes of ____ credited
Average salary of ____ is ____
Maximum salary amongst ____ is ____
Minimum salary amongst ____ is ____
*/


public class Solution {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
String[] count = sc.nextLine().split(" ");

EngineerFirm e = new EngineerFirm(Integer.parseInt(count[0]));
AccountantFirm a = new AccountantFirm(Integer.parseInt(count[1]));

count = sc.nextLine().split(" ");

int[] incomeEngineers = new int[count.length];
for (int i=0; i < count.length; i++) {
incomeEngineers[i] = Integer.parseInt(count[i]);
}
e.assignSalaries(incomeEngineers);

count = sc.nextLine().split(" ");
int[] incomeAccountants = new int[count.length];
for (int i=0; i < count.length; i++) {
incomeAccountants[i] = Integer.parseInt(count[i]);
}
a.assignSalaries(incomeAccountants);

e.averageSalary();
e.maxSalary();
e.minSalary();

a.averageSalary();
a.maxSalary();
a.minSalary();
}
}
Comments (2)