Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program to store and search for parcels handled by a delivery company. A parcel has the following instances variables: parcel code, length,
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
This program allows users to enter parcel records saves them in ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started