Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part II: (80 pts) ) Write a program to solve the following problem. Name the Box class Box.java and the main application A6YourName.java (use your

Part II: (80 pts) ) Write a program to solve the following problem. Name the Box class Box.java and the main application A6YourName.java (use your own name). These two classes should be stored in one package. Upload both files to Blackboard Assignment #6 link as well as document of answers.

Design a Box class (Box.java) with data members for integer length, width, and height, accessor and modifier methods and methods for area and volume. Include a default constructor setting dimensions to 1 and a parameterized constructor where the user passes in desired dimensions. Include PRE and POST comments. Test the Box class before writing the application.

Write an application (A6YourName.java) which uses Box objects. The company sells snow globes which come in a variety of cubic container boxes measured in inches. Some quantities of a snow globe (one size only) need to be shipped from one store to another. The company would like to know how many shipping boxes of various types are required and the cost for each. Packing material costs $0.0023 per cubic inch. Packing material is only needed on partially filled shipping boxes. Plastic wrap around the sealed box costs $0.0012 per square inch.

Input: The user will enter the dimensions of the shipping box. Valid dimensions are multiples of 4 inches (Ex. 4 x 8 x 12 box is acceptable while 3 x 7 x 16 box is not valid). The user enters the box cost. The user enters the snow globe dimension. Valid dimensions are multiples of 4 such that at least one globe fits in the box. (Ex. If the shipping box is 4 x 8* 8 inches, then the snow globe cannot be 8 inches or more as not even one fits.) Use error detection loops to ensure valid data (see Test Case 1). The main loop allows the user to input any number of orders, using value 0 as the sentinel (see Test Case 2).

Output: You will run 3 test cases to turn in.

Test Case 1: Error checking (see sample output)

Test Case 2: Valid data

Test Case 3: Ship box: 24 x 16 x 8

Box cost: $4.99

Snow globe: 8

Quantities: 1 5 6 50

Notes:

  • Code must make use of two Box objects, one for the shipping box and one for the snow globe container. Once the Box object is declared, only Box methods may be used.
  • Use a NumberFormat object to display the costs in Currency.

image text in transcribed

Please help

Test Case 1: Enter length, width, height of ship box: -144 Enter length, width, height of ship box: 4 -1 4 Enter length, width, height of ship box: 44 -1 Enter length, width, height of ship box: 3 4 4 Enter length, width, height of ship box: 4 3 4 Enter length, width, height of ship box: 44 Enter length, width, height of ship box: 444 Enter box cost: -1 Enter box cost: 1.99 Enter dimension of snow globe:1 Enter dimension of snow globe: 3 Enter dimension of snow globe: 8 Enter dimension of snow globe: 4 Enter number of snow globes to ship (e to quit): 1 Number of snow globes: 1 Number of shipping box needed: 1 Cost of box: $1.99 Cost of packing material: $0.00 Cost of plastic wrap: $0.12 Total Cost: $2.11 Enter number of snow globes to ship (0 to quit): Test case 2 Enter length, width, height of ship box: 16 12 4 Enter box cost: 2.99 Enter dimension of snow globe: 4 Enter number of snow globes to ship (e to quit): 1 Number of snow globes: 1 Number of shipping box(es) needed: 1 Cost of box(es): $2.99 Cost of packing material: $1.62 Cost of plastic wrap: $e.73 Total Cost: $5.34 Enter number of snow globes to ship (0 to quit): 2 Number of snow globes: 2 Number of shipping box(es) needed: 1 Cost of box (es) $2.99 Cost of packing material: $1.47 Cost of plastic wrap: $0.73 Total Cost: $5.19 Enter number of snow globes to ship (e to quit): 12 Number of snow globes: 12 Number of shipping box(es) needed: 1 Cost of box(es): $2.99 Cost of packing material: $0.8e Cost of plastic wrap: $0.73 Total Cost: $3.72 Enter number of snow globes to ship (0 to quit): 50 Number of snow globes: 50 Number of shipping box (es) needed: 5 Cost of box(es) $14.95 Cost of packing material: $1.47 Cost of plastic wrap: $3.65 Total Cost: $20.07 Enter number of snow globes to ship (e to quit): e Test Case 1: Enter length, width, height of ship box: -144 Enter length, width, height of ship box: 4 -1 4 Enter length, width, height of ship box: 44 -1 Enter length, width, height of ship box: 3 4 4 Enter length, width, height of ship box: 4 3 4 Enter length, width, height of ship box: 44 Enter length, width, height of ship box: 444 Enter box cost: -1 Enter box cost: 1.99 Enter dimension of snow globe:1 Enter dimension of snow globe: 3 Enter dimension of snow globe: 8 Enter dimension of snow globe: 4 Enter number of snow globes to ship (e to quit): 1 Number of snow globes: 1 Number of shipping box needed: 1 Cost of box: $1.99 Cost of packing material: $0.00 Cost of plastic wrap: $0.12 Total Cost: $2.11 Enter number of snow globes to ship (0 to quit): Test case 2 Enter length, width, height of ship box: 16 12 4 Enter box cost: 2.99 Enter dimension of snow globe: 4 Enter number of snow globes to ship (e to quit): 1 Number of snow globes: 1 Number of shipping box(es) needed: 1 Cost of box(es): $2.99 Cost of packing material: $1.62 Cost of plastic wrap: $e.73 Total Cost: $5.34 Enter number of snow globes to ship (0 to quit): 2 Number of snow globes: 2 Number of shipping box(es) needed: 1 Cost of box (es) $2.99 Cost of packing material: $1.47 Cost of plastic wrap: $0.73 Total Cost: $5.19 Enter number of snow globes to ship (e to quit): 12 Number of snow globes: 12 Number of shipping box(es) needed: 1 Cost of box(es): $2.99 Cost of packing material: $0.8e Cost of plastic wrap: $0.73 Total Cost: $3.72 Enter number of snow globes to ship (0 to quit): 50 Number of snow globes: 50 Number of shipping box (es) needed: 5 Cost of box(es) $14.95 Cost of packing material: $1.47 Cost of plastic wrap: $3.65 Total Cost: $20.07 Enter number of snow globes to ship (e to quit): e

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

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

How are language and thought related?

Answered: 1 week ago

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago