-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShape.java
More file actions
40 lines (39 loc) · 774 Bytes
/
Shape.java
File metadata and controls
40 lines (39 loc) · 774 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
39
40
/**
*
* @author Mudassar
*/
public class Shape {
double length,breadth,height,radius;
int s;
public void rectangle(double l,double b)
{
length=l;
breadth=b;
}
public void triangle(double l,double b,double h)
{
length=l;
breadth=b;
height=h;
}
public void circle(double r)
{
radius=r;
}
public void area(int s1)
{
s=s1;
if(s==0)
{
System.out.println("Area of rectangle:"+(length*breadth));
}
else if(s==1)
{
System.out.println("Area of triangle:"+(0.5*length*breadth*height));
}
else
{
System.out.println("Area of circle:"+(3.14*radius*radius));
}
}
}