-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
32 lines (32 loc) · 749 Bytes
/
Rectangle.java
File metadata and controls
32 lines (32 loc) · 749 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
import java.util.*;
class Rectangle
{
int length,breadth;
int area,perimeter;
void read(int length,int breadth)
{
this.length=length;
this.breadth=breadth;
}
void calculate()
{
area=length*breadth;
perimeter=2*(length+breadth);
}
void display()
{
System.out.println("Area="+area);
System.out.println("Perimeter="+perimeter);
}
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Enter length and breadth of rectangle");
int l=in.nextInt();
int b=in.nextInt();
Rectangle r1=new Rectangle();
r1.read(l,b);
r1.calculate();
r1.display();
}
}