It should be in C Imagine a publishing company that markets

It should be in C++

Imagine a publishing company that markets both book and audiocassette versions of its works. Create a class publication that stores the title (a string) and price (type float) of a publication. From this class derive two classes: book which adds a page count (type int) and tape, which adds a playing time in minutes (type float). Each of these three classes should have a getdata() function to get its data from the user at the keyboard, and a putdata() function to display its data. Write a main() program to test the book and tape classes by creating instances of them, asking the user to fill in data getdata(), and then displaying the data with putdata().

Solution

#include<iostream.h>

#include<conio.h>

Class publication

{

Private:

Char title[25];

float price;

Public:

Void getdata ()

{

Cout<<”\ enter the title”;

Cin>>title;

Cout<<”\ enter the price”

Cin>>price;

}

Void putdata()

{

Cout<<”\ title :”<<title;

Cout<<”\ price :”<< price;


}

};
Class book:public publication
{
Private:

int pagecount;
Public:

Void getdata ()

{

Cout<<”\ enter pagecount”;

Cin>>pagecount;

}
public:
Void putdata()

{

Cout<<”\ pagecount :”<<pagecount;
}
};
Class tape:public publication
{
Private:

float playingTime;
Public:

Void getdata ()

{

Cout<<”\ enter playingTime”;

Cin>>playingTime;

}
public:
Void putdata()

{

Cout<<”\ playingTime :”<<playingTime;
}
}


Void main ()

{

Publication p;
book b;
tape t;

p. getdata ();

p.putdata();

b.getdata();
b.putdata();

t.getdata();
t.putdata();

getch ();

}

sample output:

enter the title: example
enter the price: 101
title :example
price:101

enter page count: 200
pagecount:200
enter playingtime:2.05
playingtime:2.05

It should be in C++ Imagine a publishing company that markets both book and audiocassette versions of its works. Create a class publication that stores the titl
It should be in C++ Imagine a publishing company that markets both book and audiocassette versions of its works. Create a class publication that stores the titl
It should be in C++ Imagine a publishing company that markets both book and audiocassette versions of its works. Create a class publication that stores the titl

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site