I need to finish this program: A small television station is attempting to find
ID: 3541250 • Letter: I
Question
I need to finish this program:
A small television station is attempting to find its niche among the myriad offerings available on cable. They invite viewers to go to their station website and to rank their various shows on a scale from 0 to 5.
This is a small station. They do not anticipate airing more 50 shows during the period over which this data is collected.
Write a program to read this data and to produce a report giving the total number of viewers and the average rating for each show.
Input will be taken from a file named as the first parameter in the command line.
Each line of the input describes a single survey response. Each response consists of the name of the show, the number of people who watched the show together, and the rating that they gave to the show.
Survey responses for the shows are presented in the order they were received at the website. Consequently, responses for different shows are typically intermingled.
The end of input is signalled by the end of the file.
All output is sent to standard out.
For each show, you should produce a single line of output. That line will consist of the show name, the total number of viewers over all survey responses, and the average rating for that show over all survey responses. The average should be computed as a weighted average over all viewers (e.g., if 4 viewers in one response rate the show at 3.0 and 1 viewer in another response rates it as 4.0, the average rating is (4*3.0 + 1*4.0)/5 = 3.8).
The format of the output line is as follows:
The shows should be printed in the order in which they are first encountered in the input.
Given the input
the output should be
Explanation / Answer
Hey, I can do this. what is your deadline? Do not worry. I do NOT need any extra points. Just let me know if you can give sometime.