forked from akkupy/codeDump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
perimeter_shapes.java
30 lines (29 loc) · 991 Bytes
/
perimeter_shapes.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
/*Write a Java program to calculate the perimeter of different shapes
namely circle and rectangle using the concept of constructor
overloading.*/
import java.util.*;
public class perimeter_shapes {
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the radius of circle :");
int a = sc.nextInt();
System.out.println("Enter the length of rectangle :");
int b = sc.nextInt();
System.out.println("Enter the breadth of rectangle :");
int c = sc.nextInt();
perimeter_shapes obj=new perimeter_shapes(a);
perimeter_shapes obj1=new perimeter_shapes(b,c);
sc.close();
}
perimeter_shapes(int a)
{
System.out.println("Perimeter of circle is:"+(3.14*2*a));
}
perimeter_shapes(int n,int m)
{
int p=n+m;
int t=2*p;
System.out.println("Perimeter of Rectangle is:"+t);
}
}