Saturday, 12 November 2016

Write a program that defines the struct movieType and declares a variable of type movieType, prompts the user to input data about a movie, and outputs the movie data.

Assigment #1 Q#1  

Define a struct, movieType, to store the following data about a movie:     movie name (string), movie director (string), producer (string), the      year movie was released (int), and number of copies in stock.


Assume  the  definition,  which  defines  the  struct  movieType.  Write  a 
program that declares a variable of type  movieType, prompts the  user to input data 
about a movie, and outputs the movie data.


#include<iostream>
#include<string>
using namespace std;

struct movietype{ //Struct that contains information about movie
       string m_name;
       string  m_director;
       string producer;
       int y_r;
       int c_s;
};
void getinfo(); //definition of a function to get the infomation about the movie from the user
void displayinfo(); ////definition of a function to display the infomation about the movie

movietype m;

int main()
{
      
       getinfo(); //calling of a function to get data
       displayinfo(); //calling of a function to display data

       return 0;
}
void getinfo()
{
       cout << "Enter the name of Movie :";
       getline(cin, m.m_name); //takes the name of the movie from the user
       cout << "Enter the name of Movie Director :";
       getline(cin, m.m_director); //takes the name of the movie director from the user
       cout << "Enter the name of Movie Producer :";
       getline(cin, m.producer); //takes the name of the movie producer from the user
       cout << "Enter the year movie was released  :";
       cin >> m.y_r; //takes year movie was released
       cout << "Enter the number of copies in stock  :";
       cin >> m.c_s; //takes number of copies in stock
}
void displayinfo() //function that Display the Information entered by the user
{
      
       cout << endl << "Name of the Movie :" << m.m_name << endl;
       cout << "Name of the Movie Director :" << m.m_director << endl;
       cout << "Name of Movie Producer :" << m.producer << endl;
       cout << "Year movie was released  :" << m.y_r << endl;
       cout << "Number of copies in stock :" << m.c_s << endl;
}

No comments:

Post a Comment