Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Carpet Calculator Project (JAVA) Create a New Java Project called YourLastNameCarpetCalculator . The Westfield Carpet Company has asked you to write an application that calculates

Carpet Calculator Project (JAVA)

Create a New Java Project called YourLastNameCarpetCalculator.

The Westfield 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 wide is 120 square feet. To cover that floor with carpet that costs $8 per square foot would cost $960. (12 X 10 X 8 = 960.)

First, you should create a class named RoomDimension that has two fields: one for the length of the room and one for the width. The RoomDimension class should have a method that returns the area of the room. (The area of the room is the room's length multiplied by the room's width.)

Next you should create a RoomCarpet class that has a RoomDimension object as a field. It should also have a field for the cost of the carpet per square foot. The RoomCarpet class should have a method that returns the total cost of the carpet.

The figure below is a UML diagram that shows possible class designs and the relationships among the classes. Once you have written these classes, use them in an application that asks the user to enter the dimensions of a room and the price per square foot of the desired carpeting. The application should display the total cost of the carpet. Cost should be displayed as currency (i.e. with a dollar sign and exactly two decimal places).

Continuously prompt the user for input until the user chooses to end the program.

Input Validation: Do not accept unreasonable/junk values, or negative values, which must be rejected and asked for another one.

NOTE: Each class should be defined in its on class file.

image text in transcribed

PROGRAMMING GUIDELINES: A programming assignment will be assigned a grade of 0 if it fails to compile. Each program must not contain any spelling errors in the program output or points will be deducted. Each program must contain a comment section (or points will be deducted) that indicates the following: 1. Student Name 2. Program Name 3. Short Program Description 4. Due Date Programs should use appropriate spacing and indentation, in order to increase readability. Programs should only be completed in Eclipse. Use comments for clarification throughout your programs. Use meaningful variable names. Subdivide your program into mini-sections. For more difficult programs, this will make it easier to detect both syntax and logical errors. Naming Convention for mutator methods: set + fieldname (i.e. setName) Naming Convention for accessor methods: get + fieldname (i.e. getName)

RoomDimension - length : double - width : double + RoomDimension(len: double, + getArea (): double : double) + toString() : String

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

More Books

Students also viewed these Databases questions