Question
C++ 1.)Modify the following code to include struct members to hold the a movies production costs and first-year revenues; modify and test your functions accordingly
C++ 1.)Modify the following code to include struct members to hold the a movies production costs and first-year revenues; modify and test your functions accordingly the function to display MovieData information should display the first years profit (or loss).
#include
using namespace std;
//structure
struct MovieData {
string title, director_Name;
int year, length;
};
//method to read and store info
void getMovieData(MovieData& m)
{
cout << "Enter Title of the movie:";
cin >> m.title;
cout << "Enter Director name:";
cin >> m.director_Name;
cout << "Enter year of release:";
cin >> m.year;
cout << "Enter length of the movie in minutes:";
cin >> m.length;
}
//method to display output
void prntMovie(MovieData m)
{
cout << "Title:" << m.title << endl;
cout << "Director name:" << m.director_Name << endl;
cout << "Year of release:" << m.year << endl;;
cout << "Length:" << m.length << " minutes ";
}
int main()
{
//declaring objects
MovieData o1, o2;
//calling getMovieDAta
getMovieData(o1);
getMovieData(o2);
//calling prntMovie
prntMovie(o1);
prntMovie(o2);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started