Answer to Question #213207 in C++ for Hemambar

Question #213207

Write a program for a publishing company that markets both printed books and audio visual

lectures stored on CDs. Write a class Publication thatstores title and price. Derive a class book which

has an additional member as no_pages and a class Lecture with member play_time.


1
Expert's answer
2021-07-25T08:35:09-0400
#include<iostream>
 using namespace std;
 class Publication {
 private:  
 string title; 
 float price;  
 public:
 void input(){ 
 cout<< "Enter the Title:\t ";
 cin >> title;  
  cout << "Enter the Price: \t" ;  
    cin >> price; 
	 }  
	   void Output() { 
	   input();
	     cout << "The title of the book: " << title << endl;   
		    cout << "The price of book: " << price <<endl; 
			 }  
			
				  
				  
  
  };
  class Book: public Publication{
  private: 
   int no_pages;
   public:
     void InputPages(){
     	cout<<"Enter number of pages\t";
     	cin>>no_pages;
     	
     }
     void displayPage(){
     	
     	Output();
     	InputPages();
     	cout<<"The book number of pages is\t"<<no_pages<<endl;
	 }
       
	   };
	
	class Lecture: public Publication{
		private:
	float	play_time;
	public:
		void inputTime(){
			cout<<"Enter the play time \t";
			cin>> play_time;
		}
		void displayTime(){
			inputTime();
			cout<<"The play time is\t"<<play_time<<endl;
			
		}
	
	};


int main(){ 
 Book b;
 b.displayPage();


 }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS