-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAreaMethodOverloading.java
More file actions
39 lines (39 loc) · 1.13 KB
/
AreaMethodOverloading.java
File metadata and controls
39 lines (39 loc) · 1.13 KB
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
//Method Overloading
import java.io.*;
class Overload
{
int area(int l,int b)
{
int area=l*b;
return area;
}
int area(int side)
{
int area=side*side;
return area;
}
double area(double radius)
{
double area=3.14*radius*radius;
return area;
}
}
class Method
{
public static void main(String[] args)throws Exception
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Enter the length and breadth of rectangle");
int l = Integer.parseInt(br.readLine());
int b = Integer.parseInt(br.readLine());
System.out.println("Enter the side of square");
int side=Integer.parseInt(br.readLine());
System.out.println("Enter the radius of circle");
double radius=Double.parseDouble(br.readLine());
Overload o=new Overload();
System.out.println("Area of rectangle is "+o.area(l,b));
System.out.println("Area of square is "+o.area(side));
System.out.println("Area of circle is "+o.area(radius));
}
}