-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass_Obj_1.cpp
More file actions
33 lines (29 loc) · 789 Bytes
/
Copy pathClass_Obj_1.cpp
File metadata and controls
33 lines (29 loc) · 789 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
#include <iostream>
using namespace std;
class Room
{
public: //access modifier
double length;
double breadth;
double height;
double calculateArea() {
return length * breadth;
}
double calculateVolume() {
return length * breadth * height;
}
};
int main() {
// create object of Room class
Room room1;
cout<< "Enter the length:";
cin>> room1.length ;
cout<< "Enter the breadth:";
cin>> room1.breadth ;
cout<< "Enter the height:";
cin>> room1.height ;
// calculate and display the area and volume of the room
cout << "Area of Room = " << room1.calculateArea() << endl;
cout << "Volume of Room = " << room1.calculateVolume() << endl;
return 0;
}