forked from vishnu2k60/HacktoberFest2022
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanyperimeter.java
52 lines (48 loc) · 1.85 KB
/
anyperimeter.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// This program calculate perimeter value of different shapes
import java.util.Scanner;
public class perimeter{
public static void main(String[] arr){
System.out.println("Enter whoes perimeter you want to calculate(c/et/p/rec/sq): ");
// c=Circle , et=Equilateral triangle, p=Parallelogram, rec=Ractangle, sq=Square
Scanner scan = new Scanner(System.in);
String figer = scan.next();
switch(figer){
case "c":{
System.out.println("Enter value of radius(r): ");
int r = scan.nextInt();
System.out.println("Perimeter of Circle: " + (2*3.14*r));
break;
}
case "et":{
System.out.println("Enter value of side(a): ");
int a = scan.nextInt();
System.out.println("Perimeter of Equilateral triangle: " + (3*a));
break;
}
case "p":{
System.out.println("Enter two sides of parallelogram(a,b): ");
int a = scan.nextInt();
int b = scan.nextInt();
System.out.println("Perimeter of Parallelogram: " + (2*(a+b)));
break;
}
case "rec":{
System.out.println("Enter length and width of Rectangle(l,w): ");
int l = scan.nextInt();
int w = scan.nextInt();
System.out.println("Perimeter of Ractangle: " + (2*(l+w)));
break;
}
case "sq":{
System.out.println("Enter value of side(s): ");
int s = scan.nextInt();
System.out.println("Perimeter of Square: " + (4*s));
break;
}
default: {
System.out.println("none");
break;
}
}
}
}