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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Develop a Shipping Calculator Java application, which contains the concepts of a Java object and class.

  1. This Java Program must include the declaration and definition of object and class.

 

The steps for the program are outlined below:

 

  1. Create a Java class named Package that contains the following:
  2. Package should have three privateinstance variables of type double named length, width, and height
  3. Package should have one privateinstance variable of the type Scanner named input, initialized to in
  4. No-args(explicit default) public constructor, which initializes all three double instance variables to 1.0.  
  5. 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. 
  6. Public copyconstructor, with a parameter of type Package, used to duplicate an existing Package object. 
  7. 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 
  8. public voidmethod named displayDimensions which prints the dimensions as length X width X height (each value separated by a “ X “). 
  9. A public method of type double named calcVolumethat calculates the volume and returns the result as a double value. 

 

  1. Create a class named Shipment
  2. The program mustask for two separate packages to ship
  3. 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

  1. 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)
  1. The program mustindicate the more costly package (if not same cost) and by how much  
  2. The program mustcalculate and display the appropriate message (including proper dimension and cost format)  
  3. 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.  
  4. You must change the title i.e. Welcome to <your name> shipping calculator!

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Software Development
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT