-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayObjects.java
More file actions
44 lines (35 loc) · 881 Bytes
/
Copy pathArrayObjects.java
File metadata and controls
44 lines (35 loc) · 881 Bytes
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
import java.util.Scanner;
class Box{
double width, height, depth;
Box(){
}
Box(double width, double height, double depth)
{
this.width = width;
this.height = height;
this.depth = depth;
}
double volume() {
return width*height*depth;
}
}
public class ArrayObjects {
public static void main(String[] args) {
int i;
double w,h,d;
Scanner inp = new Scanner(System.in);
Box arrayBox[] = new Box[3];
for(i=0;i<3;i++) {
arrayBox[i] = new Box();
arrayBox[i].width = inp.nextDouble();
arrayBox[i].height = inp.nextDouble();
arrayBox[i].depth = inp.nextDouble();
// w = inp.nextDouble();
// h = inp.nextDouble();
// d = inp.nextDouble();
// arrayBox[i] = new Box(w,h,d);
}
for(i=0;i<3;i++)
System.out.println("Volume of Box object "+(i+1)+": "+arrayBox[i].volume());
}
}