Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Main
- {
- public static void main(String[]args)
- {
- System.out.print(new TestDriver(2.00).volume());
- System.out.print(new TestDriver(2.00).area());
- }
- }
- class TestDriver implements Shape
- {
- final double pi=3.14159;
- double r;
- public TestDriver(double r)
- {
- this.r=r;
- }
- @Override
- public double volume()
- {
- return 0.75*pi*Math.pow(r,3);
- }
- @Override
- public double area()
- {
- return 4*pi*Math.pow(r,2);
- }
- }
- interface Shape
- {
- double volume();
- double area();
- }
Add Comment
Please, Sign In to add comment