COMP1409Lab6-b2017-04 - COMP 1409 Lab 6-b Take-home lab A...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP 1409 Lab 6-b Take-home lab A local carpet company has asked you to write an application that calculates the cost of carpeting for rectangular rooms. To calculate the cost, you multiply the area of the floor (width times length) by the price per square foot of carpet. Create a class called Room . Here are the relevant attributes: double lengthInFeet double widthInFeet Provide a constructor, one which uses the appropriate mutator (set) methods to initialize the fields. The constructor accepts parameters for both instance variables. Provide an accessor (get) and a mutator (set) for each instance variable. Each mutator validates the passed parameter and uses it only if it is positive. Provide a method called calculateArea(). This method calculates and returns the room area in square feet. Create another class called CarpetCalculator . Here are the relevant attributes: double pricePerSquareFoot Room room Provide a constructor, the constructor uses the appropriate mutator (set) methods to initialize the fields. The constructor takes two parameters to initialize the instance
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern