-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArea.java
More file actions
79 lines (69 loc) · 2.42 KB
/
Area.java
File metadata and controls
79 lines (69 loc) · 2.42 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
import java.util.Scanner;
class two_D {
int length, breadth;
void getdataRectangle() {
System.out.println("Enter the dimension length and breadth");
Scanner scanner = new Scanner(System.in);
length = scanner.nextInt();
breadth = scanner.nextInt();
}
void CostRectangle() {
System.out.println("Per sheet cost Rs 40 \nThe Total cost of sheet is " + 40 * length * breadth);
}
void getdataSquare() {
System.out.println("Enter the dimension Sides");
Scanner scanner = new Scanner(System.in);
length = scanner.nextInt();
}
void CostSquare() {
System.out.println("Per sheet cost Rs 40 \nThe Total cost of sheet is " + length * length * 40);
}
}
class three_D extends two_D {
int height;
void getdataCubic() {
System.out.println("Enter the dimension length ,breadth and heigth");
Scanner scanner = new Scanner(System.in);
length = scanner.nextInt();
breadth = scanner.nextInt();
height = scanner.nextInt();
}
void CostCubic() {
int tas = length * breadth * height;
System.out.println("Per sheet cost Rs 60 \nThe Total cost of sheet is " + tas * 60);
}
}
public class Area {
public static void main(String[] args) {
two_D tD = new two_D();
three_D thD = new three_D();
System.out.println("Enter the Shape\n1.2D\n2.3D");
Scanner scanner = new Scanner(System.in);
int Shape = scanner.nextInt();
switch (Shape) {
case 1:
System.out.println("1.Square \n2.Rectangle");
Scanner scanner1 = new Scanner(System.in);
int no = scanner1.nextInt();
switch (no) {
case 1:
tD.getdataSquare();
tD.CostSquare();
break;
case 2:
tD.getdataRectangle();
tD.CostRectangle();
break;
default:
System.out.println("Invalid shape");
}
break;
case 2:
thD.getdataCubic();
thD.CostCubic();
break;
default:
System.out.println("Invalid shape");
}
}
}