-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodoverloading
More file actions
42 lines (36 loc) · 825 Bytes
/
Copy pathMethodoverloading
File metadata and controls
42 lines (36 loc) · 825 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
41
42
import java.util.Scanner;
class Mover
{
void area(double a,double b)
{
System.out.println("Area of triangle = "+0.5*a*b);
}
void area(int a,int b)
{
System.out.println("Area of rectangle = "+a*b);
}
void area(double a)
{
System.out.println("Area of circle = "+3.14*a*a);
}
}
public class MethodOverloading
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
Mover m=new Mover();
System.out.println("Enter radius of circle : ");
double r = sc.nextDouble();
m.area(r);
System.out.println("Enter length: ");
int q = sc.nextInt();
System.out.println("Enter breadth: ");
int s = sc.nextInt();
m.area(q,s);
System.out.println("Enter base and height : ");
double t = sc.nextDouble();
double p = sc.nextDouble();
m.area(t,p);
}
}