Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (50 pts) You have collected a file of movie ratings where each movie is rated from 1 (bad) to 5 (excellent). The first line

image text in transcribed
image text in transcribed
1. (50 pts) You have collected a file of movie ratings where each movie is rated from 1 (bad) to 5 (excellent). The first line of the file is a number that identifies how many ratings are in the file. Each rating then consists of two lines: the name of the movie followed by the numeric rating from 1 to 5. Here is a sample rating file with four unique movies and seven ratings: Happy Feet Happy Feet Pirates of the Caribbean Happy Feet Pirates of the Caribbean Flags of Our Fathers Gig1i Write a program that reads in a file in this format, calculates the average rating for each movie, and outputs the average along with the number of reviews. Here is the desired output for the sample data: Happy Fee:: 3 reviews, average of 4.3/5 Pirates of the Caribbean: 2 reviews, average of 3.5 5 Flags of Our Father: 1 zeview, average of 55 Gigii: 1 review, average of5 Use a map or multiple maps to generate the output. Your map should index from a string representing each movie's name to integers that store the number of reviews for the movie and the sum of the ratings for the movie. You will need to use the fstream library to read in file data. It may be helpful to discard the newline character as you read the file data. You can do this using the following line: Ein. gnore (2, ) Use it after reading any movie ratings. You will also need to clean up the title as it will contain a linefeed character at the end of it, just remove it after reading the movie name. Assume a file named "movies.txt" is used as the input file and it contains the list of movies above. This will be the test file data for your program, make sure the output matches the output above. You can use the code below to get started. include

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

2. KMPG LLP

Answered: 1 week ago

Question

5. Wyeth Pharmaceuticals

Answered: 1 week ago