-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangle.java
47 lines (42 loc) · 887 Bytes
/
Rectangle.java
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
class Rect
{
private double length;
private double breadth;
public double getLength()
{
return length;
}
public double getBreadth()
{
return breadth;
}
public void setLength(double l)
{
length=l;
}
public void setBreadth(double b)
{
breadth=b;
}
public double area(){
return(getLength()*getBreadth());
}
public double perimeter(){
return (length+breadth)*2;
}
public boolean isSquare(){
return(length==breadth);
}
}
public class Rectangle
{
public static void main(String args[]){
Rect s=new Rect();
//s.length=12;
//s.breadth=23;
s.setLength(12.56);
s.setBreadth(14.35);
System.out.println("Area: "+s.area());
System.out.println("Perimeter: "+s.perimeter());
}
}