Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IN C++ FORMAT: Write a program to read a file containing movie data (Tile, Direc

ID: 3669165 • Letter: I

Question

IN C++ FORMAT: Write a program to read a file containing movie data (Tile, Director, Year Released, Running Time) into a vector of structures. After the program reads the data from the file, have your program ask the user how he/she wants to see the data displayed on the screen. Options are: sorted by title, director, year released or running time. You may choose to have a "menu of options" function to display the menu. Use the sort function (#include) to sort the requested data. You will need different comparison functions to pass to sort() depending on what field the data will be sorted on. This is an example of a call to sort() assuming the vector name is myMovies and the user wants to sort by title: sort (myMovies.begin(), myMovies.end(), compareByTitle); The compare By Title function will sort the elements in the vector. Since the elements are structures, that is what should be passed to it as parameters: compareByTitle(Movie ml, Movie m2) The body of the compare functions will differ depending on what field within the structure needs to be compared (title, director, year released or duration) After sorting, you should display all the information of each movie: Title Director Year Released duration

Explanation / Answer

#include <iostream>
#include<string>
using namespace std;
const int SIZE = 50;
struct Moviedata
{
string movieTitle;
string movieDirector;
int yearReleased;
int runningTime;
};
void insertData(Moviedata *object,string title, string director, int year, int running);
void printData(Moviedata *object);
int main()
{
Moviedata first,second;
insertData(&first,"Fast and furious", "zacksynder", 2012, 98);
insertData(&second,"Marvel", "ken loach", 2008,25);
cout << " Here is the data for the first movie-> ";   
printData(&first);
cout<<endl<<endl;
cout << " Here is the data for the second movie-> ";   
printData(&second);
cout<<endl<<endl;
return 0;
}
void insertData(Moviedata *object,string title, string director, int year, int running)
{
object->movieTitle=title;
object->movieDirector=director;
object->yearReleased=year;
((*object).runningTime)=running; Time=running instead of ((*object).runningTime)=running.
}
void printData(Moviedata *object)
{
cout << "Movie Tittle: " << object->movieTitle << endl;
cout << "Director of the movie: " << object->movieDirector << endl;
cout << "The year the movie was released: " << object->yearReleased <<endl;
cout << "The running time of the movie in minutes: " << object->runningTime << endl;
}