The average salary

Report a typo

Imagine that you need to calculate the average (monthly) salary in a company where you work at this moment.

To do this, you need to implement the calcAverageSalary method which takes a list of salaries and calculates the value.

It is guaranteed that the company has at least one employee.

Please, do not round the result.

Sample Input 1:

4500 5200 3900

Sample Output 1:

4533.333333333333
Write a program in Java 17
import java.util.Collection;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

class CalculateAverageSalary {

private static double calcAverageSalary(Collection<Integer> salaries) {
// write your code here
return 0.0;
}

/* Please do not modify the code below */
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

List<Integer> salaries = scanner.tokens()
.map(Integer::parseInt)
.collect(Collectors.toList());

System.out.println(calcAverageSalary(salaries));
}
}
___

Create a free account to access the full topic