Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a class named Room that has two fields: length of the room and width of the room. The Room class should have a

1. Create a class named Room that has two fields: length of the room and width of the room. The Room class should have a constructor that sets the length and width. It also should have get methods for Length and Width. Finally, it should have a method that returns the area of the room where the area of the room is the rooms length multiplied by the rooms width.

2. Next, create a RoomCarpet that has a Room object as a field. It also has a field for the cost of the carpet per square foot of carpet. - The RoomCarpet class has a constructor that takes Room object and cost as an argument and creates a Room object and set the cost field. - It should also have a method that returns the total cost of the carpet i.e., room area times cost per square foot.

3. Write a Demo class that uses both of these classes and get input from the user for length, width, and cost per square foot and prints the area of the room and the cost of carpeting the room

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions