keymasterviriya1150

asdsad

Sep 27th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. class  Main
  2. {
  3.     public static void main(String[]args)
  4.     {
  5.             System.out.print(new TestDriver(2.00).volume());
  6.             System.out.print(new TestDriver(2.00).area());
  7.         }
  8.    
  9. }
  10. class TestDriver implements Shape
  11. {
  12.     final double pi=3.14159;
  13.         double r;
  14.     public  TestDriver(double r)
  15.     {
  16.         this.r=r;
  17.     }
  18.         @Override
  19.     public double   volume()
  20.     {
  21.         return 0.75*pi*Math.pow(r,3);
  22.     }
  23.          @Override
  24.     public double  area()
  25.     {
  26.         return 4*pi*Math.pow(r,2);
  27.     }
  28. }
  29.  
  30. interface Shape
  31. {
  32.     double  volume();
  33.     double  area();
  34. }
Add Comment
Please, Sign In to add comment