Write a program that uses the MovieData class you defined in 7.8a. The program p
ID: 3566222 • Letter: W
Question
Write a program that uses the MovieData class you defined in 7.8a. The program prompts "movie information: " and then reads the title, director, release year and running-time, each typed on a line by itself (use the getline function to read in the title and director strings ). The program then creates a MovieData object and uses the object to print the movie information.
Here is one sample run:
movie information: Casablanca
Michael Curtiz
1942
102
Casablanca (1942). Directed by Michael Curtiz. (102 minutes)
Explanation / Answer
#include<iostream>
#include<string.h>
using namespace std;
class moviedata
{
char title[20],director[20];
int year,running_time;
public:
void getdata()
{
getline(title);
getline(author);
cin>>year>>running_time;
}
void print
{
cout<<title<<"("<<year<<").Directed by Director."<<director<<"("<<running_time<<")";
}
};
int main()
{
moviedata m1;
m1.getdata();
m1.print();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.