Create a delivery class for a delivery service. The class contains fields to hol
ID: 3652054 • Letter: C
Question
Create a delivery class for a delivery service. The class contains fields to hold the following:- A deliver number that contains 8 digits. the first four digits represent the year, and the last four digits represent the delivery number. For ex, the 76th delivery in 2011 has a complete delivery number of 20110076.
- A code representing the delivery area. A local delivery is code 1, and a long distance delivery is a code 2.
-A weight, in pounds, of the item to be delivered,
- The fee for the delivery, as follows:
Distance Weight Fee($)
1 Under 5 Pounds 12.00
1 5 - 20 lbs 16.50
1 Over 20 lbs 22.00
2 Under 5 lbs 35.00
2 5 lbs or more 47.95
Explanation / Answer
public class DeliveryService { int deliveryYear; int deliveryNo; int completeDeliveryNo; int distanceCode; double weight; double fees; void setDeliveryNo(int deliveryYear, int deliveryNo) { String str; if (deliveryNo = 10 && deliveryNo = 100 && deliveryNo = 5 && weight 20) { fees = 22; } } else if (distanceCode == 2) { if (weight < 5) { fees = 35; } else if (weight >= 5 && weightRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.