-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeek_3.cpp
More file actions
38 lines (32 loc) · 944 Bytes
/
Copy pathWeek_3.cpp
File metadata and controls
38 lines (32 loc) · 944 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
#include <iostream>
using namespace std;
class Rectangle
{
public:
double width;
double height;
Rectangle() {
width = 1.0;
height = 1.0;
}
Rectangle(double newWidth, double newHeight){
height = newHeight;
width = newWidth;
}
double getArea(){
return height*width;
}
double getPerimeter(){
return 2*height+2*width;
}
};
int main()
{
Rectangle rectangle1(4,40);
Rectangle rectangle2(3.5,35.9);
cout<<"The Area of Rectangle of height,"<<rectangle1.height<<" and width,"<<rectangle1.width<<" is:"<<
rectangle1.getArea()<<" and Perimeter is:"<< rectangle1.getPerimeter()<<endl;
cout<<"The Area of Rectangle of height,"<<rectangle2.height<<" and width,"<<rectangle2.width<<" is:"<<
rectangle2.getArea()<<" and Perimeter is:"<< rectangle2.getPerimeter()<<endl;
return 0;
}