Ask Question
14 April, 23:01

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)

+4
Answers (1)
  1. 14 April, 23:13
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers