Answer to Question #58869 in C++ for adam

Question #58869
Write a program that uses a structure named MovieData to store the following information about a movie:
- Title
- Director
- Year Released
- Runnung Time (in minutes)
Your program should create two MovieData variables, store values in their members, and pass each one, in turn to a function that displays the information about the movie in a clearly formatted manner.
1
Expert's answer
2016-04-06T12:30:04-0400
#include <iostream>
#include <string>

using namespace std;

struct MovieData {
string Title;
string Director;
unsigned short YearReleased;
unsigned short RunningTime;
};

void print(MovieData &md) {
cout << "Title: " << md.Title << endl
<< "Director: " << md.Director << endl
<< "Year Released: " << md.YearReleased << endl
<< "Running Time: " << md.RunningTime << " minutes" << endl;
}

int main() {
MovieData movFirst, movSecond;
movFirst.Title = "Starship Troopers";
movFirst.Director = "Paul Verhoeven";
movFirst.YearReleased = 1997;
movFirst.RunningTime = 129;
movSecond.Title = "Alien vs. Predator";
movSecond.Director = "Paul W. S. Anderson";
movSecond.YearReleased = 2004;
movSecond.RunningTime = 108;
cout << endl;
print(movFirst);
cout << endl;
print(movSecond);
cout << endl;
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS