#include #include #include using namespace std; struct MovieData //Holds data for movie data { string title; string director; int year; int runningTime; double cost; double revenue; }; void getItems(MovieData&);//entire moviedata structure is being passed to getItems function //it is passed by reference so that getItems cans place new data //into the original structure variable void showItems(MovieData);//entire moviedata structure is being passed to showItems function //it is passed by value because showItems just needs to copy data //and does not need to modify original structure variable. int main() { MovieData movie1;//defines variable part to be a MovieData structure MovieData movie2;//defines variable part to be a MovieData structure cout << endl;//blank line cout << "Enter the following information about the first movie...\n"; getItems(movie1);//get data for first movie cout << endl; cout << "Enter the following information about the second movie...\n"; cin.get();//move past the '\n' left in the input buffer by the last input getItems(movie2);//get data for second movie cout << endl; cout << "*************************************************************\n"; cout << "The following is information about the first movie:\n"; showItems(movie1);//show items for first movie cout << endl; cout << "*************************************************************\n"; cout << "The following is information about the second movie:\n"; showItems(movie2);//show items for second movie return 0; } //================================================================================ //getItems: function stores the data input by the user in the members of MovieData //structure variable passed to the function by reference //================================================================================ void getItems(MovieData &movie) { cout << "Enter the movie title: "; getline(cin, movie.title); cout << "Enter the movie Director: "; getline(cin, movie.director); cout << "Enter the Year Released in four digits (ex.1999): "; cin >> movie.year; cout << "Enter the running time (in minutes): "; cin >> movie.runningTime; cout << "Enter the movie's production costs: "; cin >> movie.cost; cout << "Enter the movie's first-year revenue: "; cin >> movie.revenue; } //================================================================================ //showItems: function displays the data stored in the members of MovieData //structure variable passed to it //================================================================================ void showItems(MovieData movie) { cout << "Movie Title: " << movie.title << endl; cout << "Director: " << movie.director << endl; cout << "Year Released: " << movie.year << endl; cout << "Running Time: " << movie.runningTime << endl; cout << "Profit or Loss: $" << (movie.revenue-movie.cost) << endl; }