-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArea.java
More file actions
37 lines (35 loc) · 798 Bytes
/
Area.java
File metadata and controls
37 lines (35 loc) · 798 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
public class Area {
void circle()//without return type and without arguments
{
int r=4;
double area=3.14*r*r;
System.out.println("area of circle is "+ area);
}
void square(int a)//without return type and with arguments
{
int area=a*a;
System.out.println("area of square is "+ area);
}
int rectanlge()//with return type and without arguments
{
int l=4;
int b=5;
int area=l*b;
return area;
}
double triangle(int b,int h)//with return type and with arguments
{
double area=0.5*b*h;
return area;
}
public static void main(String[] arg)//main method
{
Area a1=new Area();
a1.circle();
a1.square(5);
int r=a1.rectanlge();
System.out.println("area of recantgle is "+ r);
double t=a1.triangle(5, 4);
System.out.println("area of triangle is "+ t);
}
}