import java.util.*;
public class HouseEvo
{
Scanner input = new Scanner(System.in);
private Box bottom;
private Attic top;
private double depth ;
public HouseEvo()
{
System.out.print(" Enter the depth of the house: ");
double depth = input.nextDouble();
bottom = new Box(depth);
top = new Attic(depth);
System.out.print("The volume of house is: " + bottom.volume() + top.volume());
}
public class Rectangle
{
private double length, height;
public Rectangle()
{
System.out.println("Enter the height of rectangle: " );
height = input.nextDouble();
System.out.println("Enter the length of rectangle: ");
length = input.nextDouble();
}
public double area()
{
return length * height ;
}
}
private class Box
{
private Rectangle front;
private double depth;
public Box(double depth)
{
this.depth = depth;
}
public double volume()
{
return front.area() * depth ;
}
}
private class Attic
{
private Triangle front;
private double depth;
public Attic(double depth)
{
this.depth = depth;
}
private double volume()
{
return front.area() * depth ;
}
}
private class Triangle
{
private double length, height;
public Triangle()
{
System.out.println("Enter the height of Attic : ");
height = input.nextDouble();
}
public double area()
{
return height * length * 0.5;
}
}
}
No comments:
Post a Comment