#C13211. Department Salary Summation

    ID: 42725 Type: Default 1000ms 256MiB

Department Salary Summation

Department Salary Summation

You are given a CSV formatted data via standard input. The first line of the input is the header Name,Department,Salary, followed by one or more records representing an employee's details. Each record contains the employee's name, the department they work in, and their salary.

Your task is to compute the total salary for each department and output the results in lexicographical order (sorted ascending by department name). The total salary for each department should be displayed as a floating-point number with one decimal place.

Note: Use stdin for input and stdout for output.

inputFormat

The input is provided via standard input as CSV text. The first line is always the header Name,Department,Salary. Each subsequent line represents a record with the following format:

  • Name: A string representing the employee's name.
  • Department: A string representing the department name.
  • Salary: A number representing the employee's salary.

Example:

Name,Department,Salary
John Doe,Engineering,75000
Jane Smith,Engineering,80000
Alice Johnson,HR,60000
Bob Brown,HR,55000

outputFormat

Output to standard output the total salary for each department on a separate line. Each line should contain the department name and the computed total salary separated by a comma, with the salary displayed as a floating-point number with one decimal place. The departments must be output in lexicographical order.

Following the example above, the correct output would be:

Engineering,155000.0
HR,115000.0
## sample
Name,Department,Salary
John Doe,Engineering,75000
Jane Smith,Engineering,80000
Alice Johnson,HR,60000
Bob Brown,HR,55000
Engineering,155000.0

HR,115000.0

</p>