Answer to Question #214008 in C++ for Hemambar

Question #214008

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-14T05:50:20-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