Answer:
Answered below
Step-by-step explanation:
#program is written in Java
class RoomDimension{
double length;
double width;
RoomDimension (double length, double width){
this.length = length;
this.width = width;
}
public double roomArea ( ){
return length * width;
}
}
class RoomCarpet{
RoomDimension rd;
double price;
RoomCarpet ( RoomDimension rd, double price){
this.rd = rd;
this.price = price;
}
public double totalCost( ){
double area = rd.roomArea();
return area * price;
}
}