In: Computer Science
Modify the program written for Module 2 Activity 1 (Movie Data) to include two additional members that hold the movie's production costs and first-year revenues. Modify the function that displays the movie data to display the title, director, release year, running time, and first year's profit or loss.
Source Code:
#include <iostream>
using namespace std;
const int SIZE= 50;
struct MovieData
{
char title[SIZE];
char directors [SIZE];
int year [SIZE];
int runTime[SIZE];
int cost[SIZE];
int revenue[SIZE];
};
void GetMovieData (MovieData movieArray[], int size);
void GetCostRev (MovieData movieArray [], int size);
void printMovieData(MovieData movieArray[], int size);
int ProfitOrLoss(MovieData movieArray[], int size);
int main()
{
const int size1=50;
const int size2=50;
MovieData movie1[size1], movie2[size2];
GetMovieData (movie1, size1);
printMovieData (movie1, size1);
GetMovieData (movie2, size2);
printMovieData (movie2, size2);
GetMovieData (movie1, size1);
printMovieData (movie1, size1);
GetMovieData (movie2, size2);
printMovieData (movie2, size2);
return 0;
}
void GetMovieData(MovieData movieArray[], int size)
{
cout <<"Enter the title of the Movie: ";
cin >>movieArray[size].title;
cout <<"Enter the name of the directors: ";
cin >>movieArray[size].directors;
//cout <<"Enter the release date of the movie: ";
// cin >>movieArray[].year;
// cout <<"Enter the running time of the movie in minutes: ";
// cin >>movieArray[].runTime;
}
void GetCostRev(MovieData movieArray[], int size)
{
cout <<"What is the costs of " <<endl;
cout <<"the movie " <<movieArray[size].title <<" ? " ;
//cin >> movieArray[size].cost;
//cout<< "What were its revenues?: " ;
//cin >> movieArray[size].revenue;
}
int ProfitOrLoss (MovieData movieArray[], int size)
{
int profit=0, loss= 0;
if (movieArray[size]. revenue)
{
profit+=movieArray[size].revenue - movieArray[size].cost;
cout <<endl;
cout<<"First Years profits: " <<profit <<endl;
cout <<endl;
return profit;
}
if(movieArray[size].cost > movieArray[size].revenue)
{
loss +=movieArray[size].revenue - movieArray[size].cost;
cout <<endl;
cout <<"First years loss: " <<loss<<endl;
cout <<endl;
}
return loss;
}
void printMovieData(MovieData movieArray[], int size)
{
cout <<endl <<endl;
cout<<"-----------------------------------------------" <<endl;
cout<< "\t\t Movie Data "<<endl;
cout <<"---------------------------------------------------"<<endl;
cout <<"Movie Title |" <<movieArray[size].title <<endl;
cout <<" |" <<endl;
cout <<"Director |" <<movieArray[size].directors<<endl;
cout <<" |" <<endl;
cout <<"Release Year |" <<movieArray[size].year <<endl;
cout <<" |" <<endl;
cout <<"Movie Runtime in minutes |" <<movieArray[size].runTime <<endl;
cout <<" |" <<endl;
cout <<endl;
}
Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! ===========================================================================