Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Java : Create a class called box that has the following attributes (variables): length, width, height (in inches), weight (in pounds), address (1 line),

For Java :
image text in transcribed
Create a class called "box" that has the following attributes (variables): length, width, height (in inches), weight (in pounds), address (1 line), city, state, zip code. These variables must be private. Create setter and getter methods for each of these variables. Also create two constructors for the box class, one default constructor that takes no parameters and sets everything to default values, and one which takes parameters for all of the above. Create a calcShippingPrice method that returns the cost of shipping a box, using the following formula Shipping price for a single box = (((length + width + height) $0.50)(weight $1.00)) Finally, create a print method that prints length, width, height, address, city, state, zip code and shipping price to the screen You may not end up needing all of the above methods in main but you still need to create and test them all so that your box class is versatile and can be used by others Main should create an array of 3 boxes. Have the user enter the nformation for each box, then display the information for all boxes as well as the total shipping price or all boxes combined Input validation: Length, width, height, weight should all be positive. If negative or not supplied set to 0 Address needs no input validation, but can have spaces in it, if not supplied set to blank City needs no input validation but can have spaces in it, if not supplied set to blank State should be exactly two letters long. If invalid or not supplied set to XX" Zip code should be 5 digits and positive (no leading zeros), if invalid or not supplied set to 0 Input validation should be done in your setter methods and/or constructors as needed to ensure no bad data can get in to the class variables. Invalid input should instead set the value to a default as specified above

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Identify the risks associated with not planning.

Answered: 1 week ago

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago

Question

6. What data will she need?

Answered: 1 week ago