Ask Question
6 March, 08:56

The ABC Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor (width times length) by the price per square foot of carpet. For example, the area of floor that is 12 feet long and 10 feet wideis 120 square feet. To cover that floor with carpet that costs $8per square footwould cost $960. (12x10x8 = 960)

+2
Answers (1)
  1. 6 March, 11:44
    0
    class RoomDimension

    {

    double length;

    double width;

    public RoomDimension (double len, double w)

    {

    length = len;

    width = w;

    }

    public double getLength ()

    {

    return length;

    }

    public double getWidth ()

    {

    return width;

    }

    public double getArea ()

    {

    return length * width;

    }

    public String toString ()

    {

    String output;

    output = "Room dimensions:/nLength: " + length + "/nWidth: " + width + "/nArea: " + getArea ();

    return output;

    }

    }

    And the code for RoomCarpet. java:

    class RoomCarpet / /extends RoomDimension

    {

    RoomDimension size;

    double carpetCost;

    public RoomCarpet (RoomDimension dim, double cost)

    {

    size = new RoomDimension (dim. getLength (), dim. getWidth ());

    carpetCost = cost;

    }

    public double getTotalCost ()

    {

    return carpetCost;

    }

    public String toString ()

    {

    String output = size + "/nCarpet cost: $" + carpetCost * size. getArea ();

    return output;

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “The ABC Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers