#C1758. Calculate Average Feedback Score
Calculate Average Feedback Score
Calculate Average Feedback Score
You are given a series of feedback entries. Each entry is provided on a new line and contains a category name and a feedback score separated by a space. The input terminates with a line containing only "END".
Your task is to compute the average feedback score for each category. The average must be rounded to two decimal places and displayed in the format: CategoryName: average_score
. The categories should be output in the order in which they first appear in the input.
For example, if the input is:
Work Quality 8 Initiative 7 Teamwork 9 Work Quality 10 Initiative 9 END
The output should be:
Work Quality: 9.00 Initiative: 8.00 Teamwork: 9.00
Note: If a category appears multiple times, its average is computed over all its scores.
inputFormat
The input is provided via standard input (stdin) and consists of multiple lines. Each line (except the last one) contains a feedback entry in the format:
CategoryName Score
The last line contains the string END
, which signifies the end of input.
outputFormat
Output the average feedback score for each category to standard output (stdout). Each line of the output should follow the format:
CategoryName: average_score
where average_score
is the average score for that category, rounded to two decimal places. The categories are listed in the order they first appear in the input.
Work Quality 8
Initiative 7
Teamwork 9
Work Quality 10
Initiative 9
END
Work Quality: 9.00
Initiative: 8.00
Teamwork: 9.00
</p>