-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBook.cpp
51 lines (43 loc) · 1.2 KB
/
Book.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
using namespace std;
class book{
int book_number ;
string title ;
float price;
int quantity ;
float total_price = 0;
public:
void EnterValue(){
cout << "Enter Book Number : " ;
cin >> book_number;
cout << "Enter Book Title : ";
cin >> title;
cout << "Enter Price of the book : ";
cin >> price ;
cout << "Enter the Quantity of the book : ";
cin >> quantity ;
}
void CalculateTotalPrice(){
total_price = quantity * price ;
cout << "The Total Price of Book " << title << " is " << total_price << endl;
}
void Display(){
cout << "Book Details ----------> " << endl;
cout << "Book Number : " << book_number << endl;
cout << "Book Title : " << title << endl;
cout << "Price Per Book : " << price << endl;
cout << "Quantity Available : " << quantity << endl;
CalculateTotalPrice();
}
};
int main(){
book Percy ;
Percy.EnterValue();
Percy.CalculateTotalPrice();
Percy.Display() ;
cout << "-------------------" << endl;
book King ;
King.EnterValue();
King.CalculateTotalPrice();
King.Display() ;
}