forked from 20ayan/Hacktoberfest22
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshp.java
More file actions
61 lines (41 loc) · 1.15 KB
/
shp.java
File metadata and controls
61 lines (41 loc) · 1.15 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
import java.util.*;
class shape{
private float a=1,b=1,c=1;
shape(float x){
a=x;
b=x;
}
shape(float x,float y){
a=x;
b=y;
}
shape(float x,float y,float z){
a=x;
b=y;
c=z;
}
float area(){
return (a*b*c);
}
}
class shp {
public static void main (String args[]) {
Scanner sc = new Scanner(System.in);
float a,b;
System.out.println("Enter the side of square : ");
a = sc.nextFloat();
b = sc.nextFloat();
shape sq = new shape(a,b);
System.out.println("Enter the sides of rectangle : ");
a = sc.nextFloat();
b = sc.nextFloat();
shape rect = new shape(a,b);
System.out.println("Enter the height and base of triangle : ");
a = sc.nextFloat();
b = sc.nextFloat();
shape tri = new shape(a,b,0.5f);
System.out.println("Area of square : "+sq.area());
System.out.println("Area of reactangle : "+rect.area());
System.out.println("Area of triangle : "+tri.area());
}
}