Write a program to store and search for parcels handled by a delivery company. A parcel...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program to store and search for parcels handled by a delivery company. A parcel has the following instances variables: parcel code, length, width, height and weight. Length, width and height are measured in centimeter and weight is measured in Kg. The delivery fee of a parcel is calculated as follow: First Kg or less Additional weight above 1st Kg $3 $1 per kg or part of Weight is 2.1 Kg Example 1st Kg → $3 Next 1 Kg → $1 Next 0.1 Kg → $1 Delivery fee → $5 A parcel has a volumetric weight calculated as follow: volumetric weight = parcel volume/5000 The greater value between weight and volumetric weight will be used to calculate the delivery fee. Here is an example. Parcel length, width, height Volume Volumetric weight Physical weight Actual weight used in calculation Delivery fee 10, 20, 30 10 x 20 x 30 = 6000 6000/5000 1.2 Kg = 1 Kg 1.2 Kg $3 +$1 = $4 An express parcel is guaranteed to be delivered within 8 hours. For express parcel, the delivery fee is calculated as follow: Express parcel Usual delivery fee + additional 20% Long distance, express parcel Usual delivery fee + additional 35% The program will allow user to enter parcel records and save them in an ArrayList. Each record is either a usual parcel or an express parcel. The following screenshots illustrate the data entry process. Parcel code: p1 Length: 10 Width: 10 Height: 20 Weight: 1.2 Express (y/n)? n Parcel code: p2 Length: 10 Width: 20 Height: 30 Weight: 2 Express (y/n)? y Long distance (y/n)? n Parcel code: p3 Length: 20 Width: 10 Height: 5 Weight: 0.8 Express (y/n)? y Long distance (y/n)? y When the data entry is completed, the program will display the following options. 1 Show all items 2 Show express items 3 Quit Your selection: For option 1, the program will display all parcels. Your selection: 1 P1 $5.0 P2 $6.0 Express P3 $6.0 Express P4 $8.0 For option 2, the program will only the express parcels. Your selection: 2 Express P3 $6.0 Express P4 $8.0 Your program should consist of three classes as follow: class Instance variables Constructor Parcel code length, width, height weight You may declare additional instance variable(s) as you deem fit. The constructor will receive four parameters and initialize the instance variables accordingly. getCode Get methods getLength getWidth getHeight getVolume Instance method Instance method Instance method Instance method Parameters: None Returns: The parcel volume. getVolumetricWeight Parameters: None Returns: The volumetric weight. getFee Parameter: None Returns: The delivery fee based on the weight or volumetric weight. toString Parameters: None Returns: A descriptive String class Instance variables Constructor Get methods Instance method Instance method Parcel8 (Subclass of Parcel) long distance You may declare additional instance variable(s) as you deem fit. The constructor will receive appropriate parameters for initializing the instance variables. getLongDistance getFee Parameters:None Returns: Usual delivery fee + additional fee toString Parameters: None Returns: A descriptive String. class Static method XX_YourName_Lab3 where XX is your tutorial class (e.g. T1, T2, etc.) main Prompts user to enter parcel records (instances of Parcel and Parcel8). Saves the records in an ArrayList of Parcel. Allows user to view the records all parcels ⚫ only the expressed parcels (Parcel8) Source code comments Please include appropriate comments in the program. Write a program to store and search for parcels handled by a delivery company. A parcel has the following instances variables: parcel code, length, width, height and weight. Length, width and height are measured in centimeter and weight is measured in Kg. The delivery fee of a parcel is calculated as follow: First Kg or less Additional weight above 1st Kg $3 $1 per kg or part of Weight is 2.1 Kg Example 1st Kg → $3 Next 1 Kg → $1 Next 0.1 Kg → $1 Delivery fee → $5 A parcel has a volumetric weight calculated as follow: volumetric weight = parcel volume/5000 The greater value between weight and volumetric weight will be used to calculate the delivery fee. Here is an example. Parcel length, width, height Volume Volumetric weight Physical weight Actual weight used in calculation Delivery fee 10, 20, 30 10 x 20 x 30 = 6000 6000/5000 1.2 Kg = 1 Kg 1.2 Kg $3 +$1 = $4 An express parcel is guaranteed to be delivered within 8 hours. For express parcel, the delivery fee is calculated as follow: Express parcel Usual delivery fee + additional 20% Long distance, express parcel Usual delivery fee + additional 35% The program will allow user to enter parcel records and save them in an ArrayList. Each record is either a usual parcel or an express parcel. The following screenshots illustrate the data entry process. Parcel code: p1 Length: 10 Width: 10 Height: 20 Weight: 1.2 Express (y/n)? n Parcel code: p2 Length: 10 Width: 20 Height: 30 Weight: 2 Express (y/n)? y Long distance (y/n)? n Parcel code: p3 Length: 20 Width: 10 Height: 5 Weight: 0.8 Express (y/n)? y Long distance (y/n)? y When the data entry is completed, the program will display the following options. 1 Show all items 2 Show express items 3 Quit Your selection: For option 1, the program will display all parcels. Your selection: 1 P1 $5.0 P2 $6.0 Express P3 $6.0 Express P4 $8.0 For option 2, the program will only the express parcels. Your selection: 2 Express P3 $6.0 Express P4 $8.0 Your program should consist of three classes as follow: class Instance variables Constructor Parcel code length, width, height weight You may declare additional instance variable(s) as you deem fit. The constructor will receive four parameters and initialize the instance variables accordingly. getCode Get methods getLength getWidth getHeight getVolume Instance method Instance method Instance method Instance method Parameters: None Returns: The parcel volume. getVolumetricWeight Parameters: None Returns: The volumetric weight. getFee Parameter: None Returns: The delivery fee based on the weight or volumetric weight. toString Parameters: None Returns: A descriptive String class Instance variables Constructor Get methods Instance method Instance method Parcel8 (Subclass of Parcel) long distance You may declare additional instance variable(s) as you deem fit. The constructor will receive appropriate parameters for initializing the instance variables. getLongDistance getFee Parameters:None Returns: Usual delivery fee + additional fee toString Parameters: None Returns: A descriptive String. class Static method XX_YourName_Lab3 where XX is your tutorial class (e.g. T1, T2, etc.) main Prompts user to enter parcel records (instances of Parcel and Parcel8). Saves the records in an ArrayList of Parcel. Allows user to view the records all parcels ⚫ only the expressed parcels (Parcel8) Source code comments Please include appropriate comments in the program.
Expert Answer:
Answer rating: 100% (QA)
This program allows users to enter parcel records saves them in ... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
QUIZ... Let D be a poset and let f : D D be a monotone function. (i) Give the definition of the least pre-fixed point, fix (f), of f. Show that fix (f) is a fixed point of f. [5 marks] (ii) Show that...
-
In Exercises 6780, begin by graphing the square root function, f(x) = x. Then use transformations of this graph to graph the given function. h(x) = x + 1 1 Vx+1-1
-
The management of Luis Inc., a small private company that uses the cost recovery impairment model, was discussing whether certain equipment should be written down as a charge to current operations...
-
What is meant by relative profitability?
-
Explain with neat sketch the principle and construction of vapor absorption refrigeration system.
-
Mr. Rogers, an unmarried individual, had the following income items. Salary ................................................................. $512,100 Interest income...
-
What is MATLAB? Pros and cons.
-
The proposed rates were not in the range the CEO expected given the pricing analysis. The CEO has asked the pricing actuary to verify the total projected loss cost excluding potential large storm...
-
Consider the linear programming problem given by Maximize Z=8x,-4X2+4X3 subject to -2x, +X2+3x3 2 11, X1-X2+2X32 6, X1,X2;X3 20. Prepare problem for a dual simplex method and solve.
-
How much will be accumulated at the end of 25 years if an investor sets aside $450 at the end of each month and earns an average return of 9.5%?
-
Calculate the amount of loss because of the NPT for each rig in 2018. NPT2018 NPTHours NPT Percentage CostImpact(USD) Rig1 648.25 8.04% 748,843.80 Rig2 734.50 9.21% 825,000.00 Rig3 658.50 8.06%...
-
Why do firefighters need to know what to expect on a call? Discuss.
-
Borrowed $83,500 from a bank, signing a short-term note payable. Provided $106,200 in service to customers, with $100,000 on account and the rest received in cash. Purchased equipment for $189,000 in...
-
How to calculate coupon bond's Yields to Maturity? Table 1 Yields to Maturity on a 10%-coupon-Rate Bond Maturing in Ten Years (Face Value = $1,000) Price of Bond ($) Yield to Maturity (%) 1,200 7.13...
-
The table below indicates the carrying amounts (and cost), and fair values of Quintox's FV-OCI investments as of their fiscal year end, November 30, 2017. Investments Carrying Amount Fair Value...
-
In your readings, there were many examples given for nurturing close family relationships in this ever-evolving technological society we live in Based upon your readings and research describe three...
-
A convex polygon is a polygon with the property that any line segment whose endpoints are on the polygon lies entirely within the polygon. The convex hull problem consists of finding the smallest...
-
Write a program to implement the following strategy for multiplying two sparse polynomials P1, P2 of size M and N, respectively. Each polynomial is represented as a linked list of objects consisting...
-
Does either Prim's or Kruskal's algorithm work if there are negative edge weights?
-
A second-order dynamic system is modeled as \[9 \ddot{x}+6 \dot{x}+\frac{10}{9} x=14 \delta(t), \quad x(0)=0, \quad \dot{x}(0)=-\frac{1}{4}\] a. Find the response \(x(t)\) in closed form. b. Plot the...
-
Consider a first-order system with time constant \(\tau\) and zero initial condition. Find the system's unit-step response for \(\tau=\frac{1}{3}\) and \(\frac{2}{3}\), plot the two curves versus \(0...
-
a. Identify the damping type and find the free response. b. Plot the free response by using the initial command. \(\ddot{x}+3 \dot{x}+4 x=0, \quad x(0)=\frac{2}{5}, \quad \dot{x}(0)=0\)
Study smarter with the SolutionInn App