Advertisement
mmayoub

TestBox.java

Jan 28th, 2023
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. package proj27012023;
  2.  
  3. public class TestBox {
  4.     public static void main(String[] args) {
  5.         Box b1 = new Box(5, 7, 12);
  6.  
  7.         b1.setLength(10.0);
  8.         System.out.println("Volume=" + b1.getVolume());
  9.         System.out.println(b1);
  10.  
  11.         double v = b1.getVolume();
  12.         double l = Math.pow(v, 1.0 / 3.0);
  13.  
  14.         Box b2 = new Box(l, l, l);
  15.         System.out.println(b1.getVolume());
  16.         System.out.println(b2.getVolume());
  17.  
  18.         if (Math.abs(b1.getVolume() - b2.getVolume()) < 0.000001)
  19.             System.out.println("OK");
  20.         else {
  21.             System.out.println("Error");
  22.         }
  23.  
  24.     }
  25.  
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement