Answer to Question #156386 in C++ for Ansil Rahim

Question #156386

 Define a class Book with data members with book id,book name,author ,quantity and price. 

If the price of a book is above 500 ,customer will get a discount of 10%. Write C++ program 

to prepare purchase bill of a book.


1
Expert's answer
2021-01-18T08:14:20-0500


#include<iostream>

using namespace std;
class book{
public:
    int id,quantity;
    char name[10],author[15];
    double price;
    void display(){
    
cout<<"Enter book id"<<endl;
cin>>id;
cout<<"Enter book name"<<endl;
cin>>name;
cout<<"Enter book author"<<endl;
cin>>author;
cout<<"Enter book price"<<endl;
cin>>price;

cout<<"Enter book quantity"<<endl;
cin>>quantity;
if(price>500)
price=price*0.90;


    cout<<"ID="<<id<<"\tname="<<name<<"\tauthor="<<author<<"\tprice="<<quantity*price<<endl;
    
    }

};
int main(){
book b;
b.display();

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

Ansil
18.01.21, 17:14

Thanks for everything

Leave a comment

LATEST TUTORIALS
New on Blog