-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass-Book.cpp
More file actions
57 lines (56 loc) · 1.07 KB
/
Class-Book.cpp
File metadata and controls
57 lines (56 loc) · 1.07 KB
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
52
53
54
55
56
57
/*
**************************
Program Name :: Find Detail the most costly book
Program Description :: In this Program Class Book object with three data members book ID , pages & prices and four member functions
get() , show () , set() and getprice().
Program Date :: June 02,2023
Program Author :: Habiba
**************************
*/
#include <iostream>
using namespace std;
class Book
{
private:
int bookID , Pages ;
float Price ;
public:
void get()
{
cout<<"Enter a Book ID :";
cin>>bookID;
cout<<"Enter a Pages :";
cin >>Pages ;
cout<<"Enter a Prices :";
cin >>Price ;
}
void show()
{
cout<<" BookID :"<<bookID <<endl;
cout<<"Pages :" << Pages <<endl ;
cout<< "Prices :"<< Price << endl;
}
void set(int id , int pg , float pr)
{
bookID = id ;
Pages = pg ;
Price = pr ;
}
int getPrice()
{
return Price ;
}
};
int main()
{
system ("cls");
Book b1,b2 ;
b1.get();
b2.set(2 , 320 , 150.7);
cout<<"\n The detail of costly book :"<<endl ;
if (b1.getPrice()>b2.getPrice())
b1.show();
else
b2.show();
return 0;
}