Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

It should be in C++ Imagine a publishing company that markets both book and audi

ID: 3782589 • Letter: I

Question

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().

Explanation / Answer

#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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote