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.
#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;}
Comments
Thanks for everything
Leave a comment