Question: Create a class named Shipment The program must ask for two separate packages to ship The program must calculate the cost difference using the difference

  1. Create a class named Shipment
  2. The program must ask for two separate packages to ship
  3. The program must calculate 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):  
  2. If there is no difference, display the costs as the same  
  3. If the cost of one is less than twice the other, display that it is "slightly more than"  
  4. If the cost of one is less than three times the other, display that it is "twice"  
  5. If the cost of one is less than four times the other, display that it is "triple"  
  6. If the cost of one is less than five times the other, display that it is "quadruple"  
  7. Otherwise, display that as a calculated multiple (eg 5x, 6x etc)
  8. The program must indicate the more costly package (if not same cost) and by how much  
  9. The program must calculate and display the appropriate message (including proper dimension and cost format)  
  10. 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 must match the samples.  
  11. You must change the title i.e. Welcome to shipping calculator! 

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

class Shipment constructorvolume thisvolume volume thisbasePrice 3 thispricePerUnit 1 calculateCost ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!