Create a class called RoomCarpet that has three private instance variables – room length and width in foot (double) and carpet cost per square foot (double). Additionally, the class should have: a. A constructor that takes room length, room width and carpet cost per square foot. The constructor sets the class variables to these values and in case any of these values is negative, set its instance variable to zero. b. A mutator method (set) and an accessor method (get) for the carpet cost variable only. c. A method getArea that returns the area of the room. The area of the room is computed by multiplying the room's length by the room's width. d. A method getTotalCost that returns the total cost of the carpet. The total cost is computed by multiplying the room area by the carpet cost per square foot.   Part (2) Write a Java application that asks the user to enter the length and width of a room and the cost per square foot of the carpeting. Create an object from RoomCarpet class you defined in Part (1) and use it to display the room area and the total cost of the carpet.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

hello 

This is in java 

 

Create a class called RoomCarpet that has three private instance variables – room length
and width in foot (double) and carpet cost per square foot (double). Additionally, the class
should have:
a. A constructor that takes room length, room width and carpet cost per square foot. The
constructor sets the class variables to these values and in case any of these values is
negative, set its instance variable to zero.
b. A mutator method (set) and an accessor method (get) for the carpet cost variable only.
c. A method getArea that returns the area of the room. The area of the room is
computed by multiplying the room's length by the room's width.
d. A method getTotalCost that returns the total cost of the carpet. The total cost is
computed by multiplying the room area by the carpet cost per square foot. 

 Part (2)
Write a Java application that asks the user to enter the length and width of a room and the
cost per square foot of the carpeting. Create an object from RoomCarpet class you defined
in Part (1) and use it to display the room area and the total cost of the carpet.

 

 
Create a class called RoomCarpet that has three private instance variables
and width in foot (double) and carpet cost per square foot (double). Additionally, the class
room length
should have:
a. A constructor that takes room length, room width and carpet cost per square foot. The
constructor sets the class variables to these values and in case any of these values is
negative, set its instance variable to zero.
b. A mutator method (set) and an accessor method (get) for the carpet cost variable only.
c. A method getArea that returns the area of the room. The area of the room is
computed by multiplying the room's length by the room's width.
d. A method getTotalCost that returns the total cost of the carpet. The total cost is
computed by multiplying the room area by the carpet cost per square foot.
Part (2)
Write a Java application that asks the user to enter the length and width of a room and the
cost per square foot of the carpeting. Create an object from RoomCarpet class you defined
in Part (1) and use it to display the room area and the total cost of the carpet.
Transcribed Image Text:Create a class called RoomCarpet that has three private instance variables and width in foot (double) and carpet cost per square foot (double). Additionally, the class room length should have: a. A constructor that takes room length, room width and carpet cost per square foot. The constructor sets the class variables to these values and in case any of these values is negative, set its instance variable to zero. b. A mutator method (set) and an accessor method (get) for the carpet cost variable only. c. A method getArea that returns the area of the room. The area of the room is computed by multiplying the room's length by the room's width. d. A method getTotalCost that returns the total cost of the carpet. The total cost is computed by multiplying the room area by the carpet cost per square foot. Part (2) Write a Java application that asks the user to enter the length and width of a room and the cost per square foot of the carpeting. Create an object from RoomCarpet class you defined in Part (1) and use it to display the room area and the total cost of the carpet.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY