Answer to Question #284301 in C++ for amna

Question #284301

Start with the publication, book and tape classes. Add base class sales that holds an array of three floats so that it can record the dollar sales of a particular publication for the last three months. Include a getdata() function to get three sale amount from the user and a putdata() function to display the sales figure. Alter the book and tape classes, so they are derived from both publication and sales. An object of book or tape should input and output and sales data along with other data. Write a main function to create a book and tape object and exercise their input/output capabilities


1
Expert's answer
2022-01-19T16:30:06-0500
#include <iostream>
#include <string>
#include <conio.h>


using namespace std;




class publication
{
private:
	string title;
	string author;
	float price;
public:
	void getdata()
	{
		cout << "Enter the title of the publication: ";
		getline(cin, title);
		cout << "Enter the author of the publication: ";
		getline(cin, author);
		cout << "Enter the  price of the publication: ";
		cin >> price;


	}
	void putdata()
	{
		cout << "The publication title: " << title << "\n";
		cout << "The publication author: " << author << "\n";
		cout << "The publication price: " << price << "\n";
	}
};
class sales
{
private:
	//an array of three float
	float dollarSales[3];
public:
	void getdata()
	{
		for(int i=0;i<3;i++){
			cout << "Enter month "<<(i+1)<<" sale: ";
			cin >> dollarSales[i];	
		}
	}
	void putdata()
	{
		for(int i=0;i<3;i++){
			cout << "Month "<<(i+1)<<" sale: $" << dollarSales[i] << "\n";
		}
	}
};
class book :public publication,public sales
{
private:
	int pageNumbers;
	string ISBN;
public:
	void getdata()
	{
		publication::getdata();
		sales::getdata();
		cout << "Enter Book Page numbers: ";
		cin >> pageNumbers;
		cout << "Enter the ISBN of the book: ";
		getline(cin, ISBN);
		cin.ignore();
		
	}
	void putdata()
	{
		publication::putdata();
		sales::putdata();
		cout << "The book page numbers: " << pageNumbers << "\n";
		cout << "THe book ISBN: " << ISBN << "\n";
	}
};
class tape :public publication,public sales
{
private:
	int capacity;
	float speed;
public:
	void getdata()
	{
		publication::getdata();
		sales::getdata();
		cout << "Enter the tape capacity: ";
		cin >> capacity;
		cout << "Enter the tape speed: ";
		cin >> capacity;
	}
	void putdata()
	{
		publication::putdata();
		sales::putdata();
		cout << "The tape capacity: " << capacity << "\n";
		cout << "The tape speed: " << speed << "\n";
	}
};
int main(void)
{
	book newBook;
	tape newTape;
	newBook.getdata();
	cin.ignore();
	newTape.getdata();
	cout<<"\n";
	newBook.putdata();
	cout<<"\n";
	newTape.putdata();




	system("pause");


	return 0;
}

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