ave three privateinstance variables of type double named length, width, and height. Package should have one privateinstance variable of the type Scanner named input, initialized to in. No-args(explicit default) public constructor, which initializes all three double instance variables to 1.0. Initial(parameterized) public constructor, which defines three parameters of type double, named length, width, and height, which are used to initialize the instance variables of same name. Public copyconstructor, with a parameter of type Package, used to duplicate an existing Package object. Three public void methods named inputLength,inputWidth, and inputHeight. Each method will prompt the user for the appropriate property, and input a double value using the Scanner object input to initialize the instance variables A public voidmethod named displayDimensions which prints the dimensions as length X width X height (each value separated by a “ X “). A public method of type double named calcVolumethat calculates the volume and returns the result as a double value. Create a class named Shipment
ave three privateinstance variables of type double named length, width, and height. Package should have one privateinstance variable of the type Scanner named input, initialized to in. No-args(explicit default) public constructor, which initializes all three double instance variables to 1.0. Initial(parameterized) public constructor, which defines three parameters of type double, named length, width, and height, which are used to initialize the instance variables of same name. Public copyconstructor, with a parameter of type Package, used to duplicate an existing Package object. Three public void methods named inputLength,inputWidth, and inputHeight. Each method will prompt the user for the appropriate property, and input a double value using the Scanner object input to initialize the instance variables A public voidmethod named displayDimensions which prints the dimensions as length X width X height (each value separated by a “ X “). A public method of type double named calcVolumethat calculates the volume and returns the result as a double value. Create a class named Shipment
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
Related questions
Question
Develop a Shipping Calculator Java application, which contains the concepts of a Java object and class.
- This Java Program must include the declaration and definition of object and class.
The steps for the program are outlined below:
- Create a Java class named Package that contains the following:
- Package should have three privateinstance variables of type double named length, width, and height.
- Package should have one privateinstance variable of the type Scanner named input, initialized to in.
- No-args(explicit default) public constructor, which initializes all three double instance variables to 1.0.
- Initial(parameterized) public constructor, which defines three parameters of type double, named length, width, and height, which are used to initialize the instance variables of same name.
- Public copyconstructor, with a parameter of type Package, used to duplicate an existing Package object.
- Three public void methods named inputLength,inputWidth, and inputHeight. Each method will prompt the user for the appropriate property, and input a double value using the Scanner object input to initialize the instance variables
- A public voidmethod named displayDimensions which prints the dimensions as length X width X height (each value separated by a “ X “).
- A public method of type double named calcVolumethat calculates the volume and returns the result as a double value.
- Create a class named Shipment
- The program mustask for two separate packages to ship
- The program mustcalculate the cost difference using the difference in volume:
i.e. The base price for a package with volume <=1 is $3, for every unit increase in volume, the cost increases by $1
e.g. 1: a parcel with volume 4, the cost is $3+ $1 +$1 +$1 = $6
e.g. 2: a parcel with volume 2.5, the cost is $3 + $1.5 = $4.5
- Give the following (in order of priority):
- If there is no difference, display the costs as the same
- If the cost of one is less than twice the other, display that it is “slightly more than”
- If the cost of one is less than three times the other, display that it is “twice”
- If the cost of one is less than four times the other, display that it is “triple”
- If the cost of one is less than five times the other, display that it is “quadruple”
- Otherwise, display that as a calculated multiple (eg 5x, 6x etc)
- The program mustindicate the more costly package (if not same cost) and by how much
- The program mustcalculate and display the appropriate message (including proper dimension and cost format)
- Your code also does NOT need to worry if the user inputs an invalid value for the input (example: invalid length). The output of your code mustmatch the samples.
- You must change the title i.e. Welcome to <your name> shipping calculator!
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT