import java.util.Scanner; |
public class Main{ |
public static void main(String[] args) { |
Scanner scan = new Scanner(System.in); |
|
double length = scan.nextDouble(); |
double wide = scan.nextDouble(); |
Rectangle r = new Rectangle(length,wide); |
System.out.printf( "%.2f " ,r.getPerimeter()); |
System.out.printf( "%.2f" ,r.getArea()); |
System.out.println(); |
length = scan.nextDouble(); |
wide = scan.nextDouble(); |
double height = scan.nextDouble(); |
Cuboid c = new Cuboid (length, wide, height); |
System.out.printf( "%.2f " ,c.getPerimeter()); |
System.out.printf( "%.2f " ,c.getArea()); |
System.out.printf( "%.2f" ,c.getVolume()); |
scan.close(); |
} |
} |
class Rectangle |
{ |
private double length; |
private double wide; |
public Rectangle( double c, double k) |
{ |
length = c; |
wide = k; |
} |
public double getPerimeter() |
{ |
return (length+wide)* 2 ; |
} |
public double getArea() |
{ |
return length*wide; |
} |
public double getLength() |
{ |
return length; |
} |
public double getWide() |
{ |
return wide; |
} |
} |
class Cuboid extends Rectangle |
{ |
private double height; |
public Cuboid( double c, double k, double g) |
{ |
super (c,k); |
height = g; |
} |
public double getPerimeter() |
{ |
return ( super .getLength() + super .getWide() + height)* 4 ; |
} |
public double getArea() |
{ |
return ( super .getLength()* super .getWide() + super .getLength()*height + super .getWide()*height)* 2 ; |
} |
public double getVolume() |
{ |
return super .getLength()* super .getWide()*height; |
} |
} |