-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperimeter.java
More file actions
48 lines (44 loc) · 908 Bytes
/
perimeter.java
File metadata and controls
48 lines (44 loc) · 908 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
43
44
45
46
47
import java.util.Scanner;
class overloading
{
double p;
overloading(int r)
{
p=2*3.14*r;
System.out.println("perimeter of circle:"+p);
}
overloading(int h, int t, int b)
{
p=h+t+b;
System.out.println("perimeter of triangle:"+p);
}
overloading(int l, int b)
{
p=2*(l+b);
System.out.println("perimeter of rectangle:"+p);
}
void display()
{
}
}
class perimeter
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
overloading[] shape = new overloading[3];
System.out.println("Enter the radius of circle");
int r = sc.nextInt();
System.out.println("Enter the sides of triangle");
int h = sc.nextInt();
int t = sc.nextInt();
int q = sc.nextInt();
System.out.println("Enter the length and breadth of rectangle");
int l = sc.nextInt();
int b = sc.nextInt();
System.out.println();
shape[0] = new overloading(r);
shape[1] = new overloading(h,t,q);
shape[2] = new overloading(l,b);
}
}