Answer to Question #254037 in C++ for Kamo

Question #254037
Question 5 [15 Marks) Write a C++ programme to create a class by name Book Data Members of the class BOOK are BOOK_NO BOOK_NAME BOOK_PRICE integer 20 characters float TOTAL_COST() Calculate the cost of N books where N is passed as an argument Member Functions of the class BOOK are INPUTO function to read BOOK_NO. BOOK_NAME, BOOK_PRICE PURCHASE() Get an input for the number of copies to be purchased. It uses TOTAL_COST() function to calculate the cost of N books and prints the total cost to be paid by the user. Create the necessary object for this class to run this program effectively. (Implement the OOPS concepts Polymorphism, inheritance, and Friend function wherever it is necessary) QP
1
Expert's answer
2021-10-20T16:38:21-0400
#include<iostream>
#include<string>
using namespace std;
class BOOK
{
	int BOOK_PRICE;
	string BOOK_TITLE;
    int BOOK_NO;
    float TOTAL_COST(int N)
    {
    	int add=N*BOOK_PRICE;
        return add;
    }
public:
    void Getinfo()
    {
        cout<<"Input Number of the book : ";
        cin>>BOOK_NO;
        cout<<"Input Title of the book : ";
        getline(cin,BOOK_TITLE);
        getline(cin,BOOK_TITLE);
        cout<<"Input price of the book : ";
        cin>>BOOK_PRICE;
    }
    void Price()
    {
        int copies;
        cout<<"\nInput the number of copies needed for purchase: ";
        cin>>copies;
        float sum=TOTAL_COST(copies);
        cout<<"Total Price : "<<sum;
    }
    void display()
    {
        cout<<"Book Number : "<<BOOK_NO;
        cout<<"\nBook Title : "<<BOOK_TITLE;
        cout<<"\nPrice : "<<BOOK_PRICE;
        Price();
    }
};
int main()
{
    BOOK book;
    book.Getinfo();
    book.display();
}

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