class Room
{
                float length;
                float width;
                Room(float x,float y)
                {
                                length=x;
                                width=y;
                }
                Room(float x)
                {
                                length=width=x;
                }
                float area()
                {
                                return (length*width);
                }
}
class Test
{
                public static void main(String args[])
                {
                                Room area=new Room(10.5f,11.4f);
                                Room vol=new Room(7.3f);
                                float a,b;
                                a=area.area();
                                b=vol.area();
                                System.out.println("Area = "+a);
                                System.out.println("Volume = "+b);
                }
}

JAVA 18.PNG

Advertisements