diff --git a/OOP/Java/Lab/Week5/Box.java b/OOP/Java/Lab/Week5/Box.java new file mode 100644 index 0000000..7d8e3de --- /dev/null +++ b/OOP/Java/Lab/Week5/Box.java @@ -0,0 +1,33 @@ +import java.util.Scanner; + +class Box { + + double width; + double height; + double depth; + + public void setDimensions(double w, double h, double d) { + width = w; + height = h; + depth = d; + } + + public double getVolume() { + return width * height * depth; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + Box myBox = new Box(); + + System.out.print("Enter the width of the box:"); + int width = sc.nextInt(); + System.out.print("Enter the height of the box:"); + int height = sc.nextInt(); + System.out.print("Enter the depth of the box:"); + int depth = sc.nextInt(); + + myBox.setDimensions(width, height, depth); + System.out.println("The volume of the box is: " + myBox.getVolume()); + } +}