Project 9c Write a program that uses a structure named MovieData to store the fo
ID: 3770710 • Letter: P
Question
Project 9c
Write a program that uses a structure named MovieData to store the following information about a movie:
Movie Title
Director
Writer
Year Released
Running Time (in minutes)
The 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. The movie data can either be input by the user, or specified using assignment statements.
(30 PTS)
Solution to this please(: Im in comp science 1 so i imagine the code shouldn't be very complex (C++)
Explanation / Answer
#include<iostream>
#include <string>
using namespace std;
struct movie{
string movie_title;
string director;
string writer;
int year_released;
float running_time;
}mine,yours;
void print_movie(movie m);
int main(){
mine.movie_title="Galaxy";
mine.director="John";
mine.writer="Simon";
mine.year_released=1956;
mine.running_time=120;
yours.movie_title="Snow";
yours.director="Max";
yours.writer="Samuel";
yours.year_released=1973;
yours.running_time=130;
cout << "My favorite movie is: ";
print_movie (mine);
cout<<endl;
cout << "And yours favorite movie is: ";
print_movie (yours);
return 0;
}
void print_movie (movie m)
{
cout << m.movie_title<<endl;
cout << "Director is: ";
cout << m.director<<endl;
cout << "Writer is: ";
cout << m.writer<<endl;
cout << "Released in the year: ";
cout <<m.year_released<<endl;
cout << "and Running time is: ";
cout << m.running_time<<endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.