-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestRectangle.java
More file actions
36 lines (34 loc) · 546 Bytes
/
Copy pathtestRectangle.java
File metadata and controls
36 lines (34 loc) · 546 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
import java.util.*;
class Rectangle
{
double h;
double w;
static int count=0;
Rectangle()
{
h=1;
w=1;
count = count + 1;
}
Rectangle(double h1,double w1)
{
h=h1;
w=w1;
count = count + 1;
}
void getArea()
{
System.out.println("Rectangle area: "+(h*w)+"m2 and perimeter is: "+(2*(h+w))+"m");
}
}
public class testRectangle
{
public static void main(String args[])
{
Rectangle r1=new Rectangle();
r1.getArea();
Rectangle r2=new Rectangle(2,2);
r2.getArea();
System.out.println("Object Count: "+r2.count);
}
}