Answer:
#include <iostream>
#include <string>
using namespace std;
struct MovieData {
string Title;
string Director;
unsigned short YearReleased;
unsigned short RunningTime;
};
void displayMovieInfo(MovieData &md) {
cout << "The Title is: " << md.Title << endl
<< "The Director is: " << md.Director << endl
<< "The Year of Release: " << md.YearReleased << endl
<< "The Running Time: " << md.RunningTime << " minutes" << endl;
}
int main() {
MovieData firtMovie, secondMovie;
firtMovie.Title = "Starship Troopers";
firtMovie.Director = "Paul Verhoeven";
firtMovie.YearReleased = 1997;
firtMovie.RunningTime = 129;
secondMovie.Title = "Alien vs. Predator";
secondMovie.Director = "Paul W. S. Anderson";
secondMovie.YearReleased = 2004;
secondMovie.RunningTime = 108;
cout << endl;
displayMovieInfo(movFirst);
cout << endl;
displayMovieInfo(movSecond);
cout << endl;
system("pause");
return 0;
}
Step-by-step explanation:
In this program a structure that contains the class feilds for four attributes of a movie (Title, Director, Year Released and Running Time) we declared this with their appropriate data types.
Next we create a function (Method) called displayMovieInfo that will print a clearly formatted output of the movies when called and given appropriate parameters.
Finally we create the main function where we create two movie objects and make function calls to the displayMovieInfo and pass the two movies to the displayMovieInfo function to display their information