-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_1.cpp
More file actions
85 lines (72 loc) · 1.52 KB
/
2_1.cpp
File metadata and controls
85 lines (72 loc) · 1.52 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<iostream>
using namespace std;
class rectangularplot
{
private:
int length, width;
public:
void perimeter();
void area();
void getdata();
void display();
void changeindimension();
};
void rectangularplot::getdata()
{
cout << "\nEnter the length: ";
cin >> length;
cout << "\nEnter the width: ";
cin >> width;
}
void rectangularplot::display()
{
cout << "\nLength:" << length;
cout << "\nWidth:" << width;
}
void rectangularplot::perimeter()
{
int p;
p = 2 * length + 2 * width;
cout << "\nThe perimeter is: " << p;
}
void rectangularplot::area()
{
int a;
a = length * width;
cout << "\nThe area is: " << a;
}
void rectangularplot::changeindimension()
{
int answer, l, w;
cout << "\nDo you want to change the dimensions? (Yes = 1, No = 0): ";
cin >> answer;
if(answer == 1)
{
cout << "\nEnter the new length and width: ";
cin >> l >> w;
length = l;
width = w;
}
else
{
cout << "\nDimensions remain unchanged.";
}
}
int main()
{
rectangularplot r1, r2;
r1.getdata();
r1.changeindimension();
r1.perimeter();
r1.area();
r2.getdata();
r2.changeindimension();
r2.perimeter();
r2.area();
cout << "\nDetails of the first plot: " << endl;
r1.display();
cout << "\nDetails of the second plot: " << endl;
r2.display();
cout<<"\n24ce052_pushti";
return 0;
}