-
Notifications
You must be signed in to change notification settings - Fork 11
/
overload.java
36 lines (35 loc) · 962 Bytes
/
overload.java
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
import java.util.Scanner;
public class overload
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
System.out.print("Enter the side of square : ");
int s = sc.nextInt();
System.out.print("Enter the sides of rectangle : ");
int l = sc.nextInt();
int b = sc.nextInt();
System.out.print("Enter the radius of circle : ");
float r = sc.nextFloat();
OverloadDemo ob = new OverloadDemo();
ob.area(s);
ob.area(l,b);
ob.area(r);
}
}
class OverloadDemo
{
void area(int x)
{
System.out.println("the area of the square is "+Math.pow(x, 2)+" sq units");
}
void area(float x, float y)
{
System.out.println("the area of the rectangle is "+x*y+" sq units");
}
void area(float x)
{
double z = 3.14 * x * x;
System.out.println("the area of the circle is "+z+" sq units");
}
}