Answered step by step
Verified Expert Solution
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 :
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started