//Christian Nwogu CSC5 CH.11 Pp.681 #2
/**************************************************************************
*
* SHOW MOVIE DATA OF STRUCTURE
* _______________________________________________________________________
* This program uses a structure named MovieData to store the following
* information about a movie.
* Title
* Director
* Year Released
* Running Time
* The program creates two MovieData variables, stores 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.
* _______________________________________________________________________
* INPUT
* movie1.title
* movie1.director
* movie1.year
* movie1.time
* movie2.title
* movie2.director
* movie2.year
* movie2.time
* OUTPUT
* movie1.title
* movie1.director
* movie1.year
* movie1.time
* movie2.title
* movie2.director
* movie2.year
* movie2.time
* **********************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
/********************************************************************
* STRUCTURE: MovieData
* -----------------------------------------------------------------
* MovieData is a strucre that stores the tile, the director, year released
*, the running time of movie.
********************************************************************/
struct MovieData
{
string title; // The title of the movie
string director; // The name of director
int year; // The year when the movie was released
int time; // The running time of movie in minutes
};
/********************************************************************
* FUNCTION PROTOTYPE: ShowMovieData
* -----------------------------------------------------------------
* This function accepts an MovieData as an argument, and it displays
* the each item of the structure.
*
* Return : Nothing
********************************************************************/
void ShowMovieData(MovieData);
int main ()
{
//
// VARIABLES
MovieData movie1;
MovieData movie2;
//
// INPUT for the first movie
cout << "MOVIE #1" << endl;
cout << "Enter the title of movie \n";
getline(cin, movie1.title);
cout << "Enter the director of movie \n";
getline(cin, movie1.director);
cout << "Enter the year when the movie was released \n";
cin >> movie1.year;
cout << "Enter the running time of the movie \n\n";
cin >> movie1.time;
//
// INPUT for the second movie
cout << "MOVIE #2" << endl;
cout << "Enter the title of movie\n";
cin.ignore();
getline(cin, movie2.title);
cout << "Enter the director of movie \n";
getline(cin, movie2.director);
cout << "Enter the year when the movie was released \n";
cin >> movie2.year;
cout << "Enter the running time of the movie \n";
cin >> movie2.time;
// OUTPUT
cout << endl;
ShowMovieData(movie1);
ShowMovieData(movie2);
return 0;
}
/********************************************************************
* FUNCTION DEFINITION: ShowMovieData
* -----------------------------------------------------------------
* This function accepts an structured data of MovieData as an argument,
* and it displays the elements of the structure on console.
* This is a void function, and returns nothing.
********************************************************************/
void ShowMovieData(MovieData movie)
{
cout << "Title: " << movie.title << endl;
cout << "Director: " << movie.director << endl;
cout << "Year: " << movie.year << endl;
cout << "Time: " << movie.time << "m" << endl;
cout << endl;
}