Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Gaddis Chapter 11- Programming Challenges 1. Movie Data) Write a program called

ID: 3706945 • Letter: #

Question

(Gaddis Chapter 11- Programming Challenges 1. Movie Data) Write a program called movie.cpp that uses a structure named MovieData to store the following information about a movie Title Director Year Released Running Time in minutes) The program should create two variables of type MovieData and store values in their member variables. You may initialize the member variables any way you want to (user input or hard-coded literal values). Create a function that accepts a MovieData structure as input and displays information about the movie in a clearly formatted manner. Perform two function calls in main to display your movie information to the console. The program MUST contain the following features: A structure declaration for an ADT (abstract data type) called MovieData Initialization of two MovieData variables initialize the member variables however you want to) Implementation of a function that has a MovieData input parameter and prints the information contained in its member variables to the console A sample run of the program is shown below Moviel Title: The Shawshank Redemption Director: Frank Darabont Year: 1994 Running Time: 142 Movie2: Title: Full Metal Jacket Director: Stanley Kubrick Yea: 1987 Running Time: 116 Press any key to continue

Explanation / Answer

Here is solution for your program

#include <iostream>

#include <iomanip>

using namespace std;

const int SIZE = 50;

struct MovieData

{

char title[SIZE];

char director[SIZE];

int year;

int minutesRunning;

};

void GetMovieInfo(MovieData&, MovieData&);

void MovieDisplay(MovieData, MovieData);

int main()

{

MovieData member1, member2;

GetMovieInfo(member1, member2);

MovieDisplay(member1, member2);

return 0;

}

void GetMovieInfo(MovieData &m1, MovieData &m2)

{

cout << "First Movie ";

//Get movie title

cout << "Enter the title of the movie: ";

cin.ignore();

cin.getline(m1.title, SIZE);

//Get director's name

cout << "Enter the Director's name of the movie: ";

cin.ignore();

cin.getline(m1.director, SIZE);

//Get the release year

cout << "Enter the year the movie was released: ";

cin >> m1.year;

//Get the movie runtime in minutes

cout << "Enter runtime of the movie in minutes: ";

cin >> m1.minutesRunning;

cout << " --------------------------------- ";

cout << " Movie 2 ";

//Get movie title

cout << "Enter the title of the movie: ";

cin.ignore();

cin.getline(m2.title, SIZE);

//Get director's name

cout << "Enter the Director's name of the movie: ";

cin.ignore();

cin.getline(m2.director, SIZE);

//Get the release year

cout << "Enter the year the movie was released: ";

cin >> m2.year;

//Get the movie runtime in minutes

cout << "Enter runtime of the movie in minutes: ";

cin >> m2.minutesRunning;

}

void MovieDisplay(MovieData m1, MovieData m2)

{

cout << " --------------------------------- ";

cout << "Movie1:";

//Display the movie information

cout << " Below is the data of the movie 1 entered: ";

cout << "Title: " << m1.title << endl;

cout << "Director: " << m1.director << endl;

cout << "Year: " << m1.year << endl;

cout << "Running Time(in minutes): " << m1.minutesRunning << endl;

cout << " --------------------------------- ";

cout << "Movie2:";

//Display the movie information

cout << " Below is the data of the second movie entered: ";

cout << "Title: " << m2.title << endl;

cout << "Director: " << m2.director << endl;

cout << "Year: " << m2.year << endl;

cout << "Running Times(in minutes): " << m2.minutesRunning << endl;

}