Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i hope u answer all the questions Q3.A Consider the following problem description [7 Marks) public class Parcell public String des public int weight public
i hope u answer all the questions
Q3.A Consider the following problem description [7 Marks) public class Parcell public String des public int weight public Parcel Stringit drie weight-w:) Shipment item.Parcel FromAddress Address -Address der Name String Shipment Purcelloddress Address setFromAddrestring, phone string islocalShipment.boolean caleCoundouble City Str Phone Address Phone Citytring Phone listing toering Istring Based on the UML diagram above, write java classes for Address and Shipment as follows. Note that the class Parcel is written for you. 1. Address class a. Define the data members and the constructor of the Address per the UML above (0.5 Mark] Override the toString method such that it returns a string of the format: 10.5 Mark] (city, phone) Provide 2 getters, for the city and the phone [1 Mark] 2. Shipment class a shipment has parcel (package), sender name, sender address (fromAddress), and recipient address (toAddress). a) Define the data members and the constructor per the UML above (1 Mark] b) Define a setter for the sender address per the UML above (0.5 Mark] c) Define the method is localShipment per the UML above. The methods returns true if the shipment is in the same city, otherwise it retums false. [1 Mark] d) Define the caloCost to calculate the shipment cost as follows: (1.5 Mark] Basic cost for local shipment in the same city is SAED and for different cities is 15 AED Additional cost based on parcel weight: 5.5 AED for packages that weight up to 200 grams and 10.5 AED for packages that weight more than 200 grams Additional 5% tax (VAT) on the total cost Override the toString method such that it returns a string of the format: [1 Mark] From: name of sender To address of recipient (city, phone) Parcel parcel description Cost: cost of shipment Q4 Based on the UML in Q3, answer the following [5 marks] Write a test class with a main method to do the following: a) [1.5 Marks] Create object(s) for the following description: Salim wants to send a parcel to his friend Ali. Both Salim and Ali live in Dubai and their phones are 055- 12345678 and 050-5432123. The parcel is a scientific calculator that weighs 250 grams. [0.5 Mark] b) [1 Mark] Define an array of 100 Shipments, call the array arr. c) [0.5 Mark] Set the 5th element of arr with the shipment you defined in question a. d) [2 marks] Assume that the array is populated with 20 shipments, calculate the total cost of local shipments in the array. Java Program Q3.A Consider the following problem description [7 Marks) public class Parcell public String des public int weight public Parcel Stringit drie weight-w:) Shipment item.Parcel FromAddress Address -Address der Name String Shipment Purcelloddress Address setFromAddrestring, phone string islocalShipment.boolean caleCoundouble City Str Phone Address Phone Citytring Phone listing toering Istring Based on the UML diagram above, write java classes for Address and Shipment as follows. Note that the class Parcel is written for you. 1. Address class a. Define the data members and the constructor of the Address per the UML above (0.5 Mark] Override the toString method such that it returns a string of the format: 10.5 Mark] (city, phone) Provide 2 getters, for the city and the phone [1 Mark] 2. Shipment class a shipment has parcel (package), sender name, sender address (fromAddress), and recipient address (toAddress). a) Define the data members and the constructor per the UML above (1 Mark] b) Define a setter for the sender address per the UML above (0.5 Mark] c) Define the method is localShipment per the UML above. The methods returns true if the shipment is in the same city, otherwise it retums false. [1 Mark] d) Define the caloCost to calculate the shipment cost as follows: (1.5 Mark] Basic cost for local shipment in the same city is SAED and for different cities is 15 AED Additional cost based on parcel weight: 5.5 AED for packages that weight up to 200 grams and 10.5 AED for packages that weight more than 200 grams Additional 5% tax (VAT) on the total cost Override the toString method such that it returns a string of the format: [1 Mark] From: name of sender To address of recipient (city, phone) Parcel parcel description Cost: cost of shipment Q4 Based on the UML in Q3, answer the following [5 marks] Write a test class with a main method to do the following: a) [1.5 Marks] Create object(s) for the following description: Salim wants to send a parcel to his friend Ali. Both Salim and Ali live in Dubai and their phones are 055- 12345678 and 050-5432123. The parcel is a scientific calculator that weighs 250 grams. [0.5 Mark] b) [1 Mark] Define an array of 100 Shipments, call the array arr. c) [0.5 Mark] Set the 5th element of arr with the shipment you defined in question a. d) [2 marks] Assume that the array is populated with 20 shipments, calculate the total cost of local shipments in the array. Java ProgramStep by Step Solution
There are 3 Steps involved in it
Step: 1
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