-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.cpp
More file actions
46 lines (36 loc) · 788 Bytes
/
2.cpp
File metadata and controls
46 lines (36 loc) · 788 Bytes
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
#include <iostream>
using namespace std;
class Book {
int BookID;
string BookName;
double BookPrice;
double total_cost(int n) {
return BookPrice * n;
}
public:
void input() {
cout<<"Enter Book ID, Book name and Book Price: "<<endl;
cin >> BookID >> BookName >> BookPrice;
}
void display() {
cout << BookID << " " << BookName << " " << BookPrice << "\n";
}
void purchase() {
int n;
cout<<"Enter No.of copies: "<<endl;
cin >> n;
cout <<"Total : "<< total_cost(n) << "\n";
}
};
int main() {
Book b1, b2, b3;
b1.input();
b2.input();
b3.input();
b1.display();
b1.purchase();
b2.display();
b2.purchase();
b3.display();
b3.purchase();
}