In C++:
Today is your first day as a software engineering intern at Netflix. For your first assignment, your boss asked you to develop a function to print statistics about the most streamed TV shows. You've been given show_list.txt, a file which contains a list of some of the most popular shows. Each line contains the name of the show and number of streams separated by a single "-" delimiter.
Your function should meet the following specifications:
- The function name: tvStreamStats
- The function parameters in this order:
- string filename: the name of the file to be read
The function doesn't return values but it should:
- Print the number of lines it read
- Print the name and number of streams of the most streamed show
- Print the name and number of streams of the least streamed show
- If any ties for most or least streamed are found, keep the most recent show
- Print an error message and exit the program if the file couldn't be opened
- The function should only keep count of nonempty lines
Example file (show_list.txt):
The Office-887000
Seinfeld-675000
Bridgerton-721500
Great British Baking Show-822400
Sample run 1:
Function call:
string filename = "show_list.txt";
tvStreamStats(filename);
Output:
Number of lines read: 3.
Most streamed show: The Office with 887000 streams.
Least streamed show: Seinfeld with 675000 streams.
Sample run 2:
Function call:
string filename = "does-not-exist.txt";
tvStreamStats(filename);
Output:
Could not open file.