Use C to Create a program that prompts an employee to enter

Use C++ to:

Create a program that prompts an employee to enter information for Movie or Music in an online store.

2.     Based on the selection, create a class named Media that then prompts the user to input the appropriate information for the media and stores it in media.

3.     Music Titles in the online store have everything that Movie titles have, except for one extra identifying field: Artist.

After completing this, the information should be output to the screen.

EXAMPLE 1:

Enter Media ID: 001

Enter Media Title: Beasts of No Nation

Enter Media Genre: Drama

Enter Current Status: Available

Enter Media Type: MOVIE

****Print Out********

Media ID: 001

Media Type: MOVIE

Media Title: Beasts of No Nation

Genre: Drama

Current Status: Available

EXAMPLE 2:

Enter Media ID: 002

Enter Media Title: Hello

Enter Media Genre: Pop

Enter Current Status: Available

Enter Media Type: MUSIC

Enter Artist:

****Print Out********

Media ID: 002

Media Type: MUSIC

Media Title: Hello

Artist: Adele

Genre: Pop

Current Status: Available

Solution


#include <iostream>
#include <iomanip>
#include <cstring>

using namespace std;

class Media
{
   protected:
   int id;
   char title[50];
   string genre;
   string current_status;
  
   public:
   Media(int id,char title[50],string genre,string current_status) //parameterized constructor
   {
       this->id = id;
       strcpy(this->title,title);
       this->genre = genre;
       this->current_status = current_status;
   }
  
   void display()
   {
       cout<<\"\ Media ID: \"<<id;
       cout<<\"\ Media Title: \"<<title;
       cout<<\"\ Genre: \"<<genre;
       cout<<\"\ Current Status: \"<<current_status;
   }
  
  
};
class Music:public Media
{
   private:
   string artist;
  
   public:
   //passing parameters to base class constructor
   Music(int id,char title[50],string genre,string current_status,string artist):Media(id,title,genre,current_status)
   {
       this->artist = artist;
   }
  
   void display()
   {
       cout<<\"\ Media ID: \"<<id;
       cout<<\"\ Media Title: \"<<title;
       cout<<\"\ Genre: \"<<genre;
       cout<<\"\ Current Status: \"<<current_status;
       cout<<\"\ Artist : \"<<artist;
   }
};

int main()
{
   int id;
   string genre,current_status,media_type,artist;
   char title[50];
   cout<<\"\ Enter Media ID: \";
   cin>>id;
   cout<<\"\ Enter Media Title ended with : \";
   cin.getline(title,50,\':\');   //getline() to read a whole line ended with terminating character :

   cout<<\"\ Enter Media Genre: \";
   cin>>genre;

   cout<<\"\ Enter Current Status: \";
   cin>>current_status;
  
   cout<<\"\ Enter Media Type\";
   cin>>media_type;
   cout<<\"\ *******Print Out*******\";
   cout<<\"\ Media Type: \"<<media_type;
   if(media_type == \"MOVIE\")
   {
   Media m(id,title,genre,current_status);
   m.display();
   }
  
   else if(media_type == \"MUSIC\")
   {
       cout<<\"\ Enter artist \";
       cin>>artist;
  
   Music m(id,title,genre,current_status,artist);
   m.display();
   }


   return 0;
}

output:

Use C++ to: Create a program that prompts an employee to enter information for Movie or Music in an online store. 2. Based on the selection, create a class name
Use C++ to: Create a program that prompts an employee to enter information for Movie or Music in an online store. 2. Based on the selection, create a class name
Use C++ to: Create a program that prompts an employee to enter information for Movie or Music in an online store. 2. Based on the selection, create a class name

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site