-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharea.java
More file actions
96 lines (94 loc) · 3.06 KB
/
area.java
File metadata and controls
96 lines (94 loc) · 3.06 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package Methods;
import java.util.Scanner;
public class area {
static void main() {
Scanner in = new Scanner(System.in);
System.out.println("AREA PLATFORM : \n" +
"1. Circle\n" +
"2. Triangle\n" +
"3. Rectangle\n" +
"4. Isosceles Triangle\n" +
"5. Parallelogram\n" +
"6. Rhombus\n" +
"7. Equilateral Triangle\n");
System.out.print("Enter your choice : ");
int choice = in.nextInt();
switch(choice){
case 1:
circle();
break;
case 2:
triangle();
break;
case 3:
rectangle();
break;
case 4:
isoTriangle();
break;
case 5:
parallelogram();
break;
case 6:
rhombus();
break;
case 7:
equitri();
break;
default:
System.out.println("Enter a valid choice.");
}
}
static void circle(){
Scanner in = new Scanner(System.in);
System.out.print("Enter the radius of the circle : ");
int r = in.nextInt();
System.out.println("Area of circle : " + (3.14*r*r));
}
static void triangle(){
Scanner in = new Scanner(System.in);
System.out.print("Enter the base : ");
int b = in.nextInt();
System.out.print("Enter the height : ");
int h = in.nextInt();
System.out.println("Area of triangle : " + (0.5*b*h));
}
static void rectangle(){
Scanner in = new Scanner(System.in);
System.out.print("Enter the length : ");
int l = in.nextInt();
System.out.print("Enter the breadth : ");
int b = in.nextInt();
System.out.println("Area of rectangle : " + (l*b));
}
static void isoTriangle(){
Scanner in = new Scanner(System.in);
System.out.print("Enter the base : ");
int b = in.nextInt();
System.out.print("Enter the height : ");
int h = in.nextInt();
System.out.println("Area of triangle : " + (0.5*b*h));
}
static void parallelogram(){
Scanner in = new Scanner(System.in);
System.out.print("Enter the base : ");
int b = in.nextInt();
System.out.print("Enter the height : ");
int h = in.nextInt();
System.out.println("Area of parallelogram : " + (b*h));
}
static void rhombus(){
Scanner in = new Scanner(System.in);
System.out.print("Enter the diagonal1 : ");
int d1 = in.nextInt();
System.out.print("Enter the diagonal2 : ");
int d2 = in.nextInt();
System.out.println("Area of rhombus : " + (0.5*d1*d2));
}
static void equitri(){
Scanner in = new Scanner(System.in);
System.out.print("Enter the side : ");
int s = in.nextInt();
System.out.println("Area of triangle : " + ((Math.sqrt(3))/4)*(s*s));
}
}