fork download
  1. public class Main {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. Box box1 = new Box();
  6. /*box1.height = 10.0;
  7. box1.width = 20.0;
  8. box1.depth = 30.0;*/
  9. box1.setHeight(10.0);
  10. box1.width = 20.0;
  11. box1.depth = 30.0;
  12.  
  13. double vol=box1.getHeight()*box1.depth*box1.width;
  14.  
  15. System.out.println("VOLUME OF BOX1 IS: "+vol);
  16.  
  17. Box box2=new Box();
  18. box2.setHeight(2.0);
  19. box2.width=3.0;
  20. box2.depth=4.0;
  21.  
  22. vol=box2.getHeight()*box2.depth*box2.width;
  23.  
  24. System.out.println("VOLUME OF BOX12 IS: "+vol);
  25. }
  26.  
  27. }
  28.  
  29. class Box {
  30.  
  31. private double height;
  32.  
  33. public double getHeight() {
  34. return height;
  35. }
  36.  
  37. public void setHeight(double height) {
  38. this.height = height;
  39. }
  40.  
  41. double width;
  42. double depth;
  43. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
VOLUME OF BOX1 IS: 6000.0
VOLUME OF BOX12 IS: 24.0