Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 18, Problem 8PP

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:

7

Harry Potter and the Order of the Phoenix

4

Harry Potter and the Order of the Phoenix

5

The Bourne Ultimatum

3

Harry Potter and the Order of the Phoenix

4

The Bourne Ultimatum

4

Wall-E

4

Glitter

1

Write a program that reads 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:

Glitter: 1 review, average of 1 / 5

Harry Potter and the Order of the Phoenix: 3 reviews, average

of 4.3 / 5

The Bourne Ultimatum: 2 reviews, average of 3.5 / 5

Wall–E: 1 review, average of 4 / 5

Use a map or multiple maps to calculate the output. Your map(s) 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.

Blurred answer
Students have asked these similar questions
In the attached city list.txt file, the names of the provinces in Turkey are given in a single line according to the format given in Figure 1. In the application you will write, write the city names read from this file into the license plate list.txt file in the format shown in Figure 2. In more descriptive terms, citylist.txt is a file given to you. license plate list.txt is the file you will get with your code. city list: Adana, Adıyaman, Afyon, Ağrı, Amasya, Ankara, Antalya, Artvin, Aydın, Balıkesir, Bilecik, Bingöl, Bitlis, Bolu, Burdur, Bursa, Çanakkale, Çankırı, Çorum, Denizli, Diyarbakır, Edirne, Elazığ, Erzincan, Erzurum, Eskişehir, Gaziantep, Giresun, Gümüşhane, Hakkari, Hatay, Isparta, İçel (Mersin), İstanbul, İzmir, Kars, Kastamonu, Kayseri, Kırklareli, Kırşehir, Kocaeli, Konya, Kütahya, Malatya, Manisa, Kahramanmaraş, Mardin, Muğla, Muş, Nevşehir, Niğde, Ordu, Rize, Sakarya, Samsun, Siirt, Sinop, Sivas, Tekirdağ, Tokat, Trabzon, Tunceli, Şanlıurfa, Uşak, Van, Yozgat,…
In the input file (see image), grades are listed for the geography tests of group 2b. There have been three tests of which the grades will be included in the half-yearly report that is given to the students before the Christmas break. On each line of the input you can find the name of the student, followed by one or more under scores (’_’). These are succeeded by the grades for the tests, for example: Anne Adema____________6.5 5.5 4.5Bea de Bruin__________6.7 7.2 7.7Chris Cohen___________6.8 7.8 7.3Dirk Dirksen__________1.0 5.0 7.7 The lowest grade possible is a 1, the highest a 10. If somebody missed a test, the grade on the list is a 1. The assignment is to make the report for the geography course of group 2b, which should look like this: Report for group 2bAnne Adema has an average grade of 5.5Bea de Bruin has an average grade of 7.2Chris Cohen has an average grade of 7.3Dirk Dirksen has an average grade of 4.6End of report Use functions to structure the code in Python.
File names: color_square.py, chessboard.py, test_squares.py Positions on a chess board are identified by a letter and a number. The letter identifies the column; the number identifies the row. See the image below.   You will provide the functions that allow us to determine: if a chessboard square is either black or white, given its coordinates. If the row/column is valid or not for the standard chessboard For example, if we pass in “d” for the column and 4 for the row, your function that determines color should return the string: “BLACK”. If we pass  in "k" for the column to your function that validates columns, that function should return the boolean False. Requirements: Your function for validating the column should be able to accept upper or lowercase strings as parameters. Your functions for validating the row should be able to accept integers or strings as parameters. Your function that determines black-or-white may assume that the input has been validated prior to us calling…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY