-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructor.java
More file actions
30 lines (26 loc) · 819 Bytes
/
Constructor.java
File metadata and controls
30 lines (26 loc) · 819 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
import java.util.Scanner;
class Box {
double width, breadth, depth;
Box(double width, double breadth, double depth) {
this.breadth = breadth;
this.depth = depth;
this.width = width;
}
double sample() {
return width * breadth * depth;
}
}
public class Constructor {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.println("Enter Width :");
double width = reader.nextDouble();
System.out.println("Enter Breadth :");
double breadth = reader.nextDouble();
System.out.println("Enter Depth :");
double depth = reader.nextDouble();
Box e1 = new Box(width, breadth, depth);
double y = e1.sample();
System.out.println("Volume = " + y);
}
}