forked from PrajaktaSathe/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAreaRect.java
More file actions
32 lines (28 loc) · 758 Bytes
/
AreaRect.java
File metadata and controls
32 lines (28 loc) · 758 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
// Program to calculate the area of rectangle using return values -
package area;
class Rectangle {
public int l, b;
public void getData(int m, int n) {
l = m;
b = n;
}
public int calcArea() {
int area = l * b;
return area;
}
}
public class AreaRect {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a1, a2;
Rectangle r1 = new Rectangle();
Rectangle r2 = new Rectangle();
r1.l = 10;
r1.b = 15;
a1 = r1.l * r1.b;
r2.getData(20, 30);
a2 = r2.calcArea();
System.out.println("The area of first rectangle = " + a1);
System.out.println("The area of second rectangle = " + a2);
}
}