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