Hello
I need help in writing a java program...
Based in Richmond Hill, ABC Courier Inc. provides next day delivery service of small parcels to GTA and surrounding areas for its customers in Richmond Hill. In this assignment, you will write a (much simplified) Java program to calculate their shipping rate of a single parcel.
To simplify the calculation of the shipping cost, ABC Courier has divided its service area into three zones based on their zip codes. This information can be found in zonePostcode.txt. The shipping cost consists of a base cost, a fuel surcharge and an extra cost beyond the free weight (10lb). Zones have different rates.
For single piece shipping, the rates are:
Base rate (<=10lb) Rate per extra pound (11-20lb) Rate per extra pound( 21-75lb) Fuel surcharge
Zone 1 $9.25 $0.18 $0.17 $11.01
Base rate (<=10lb) Rate per extra 5 pound (11-20lb) Rate per extra 5 pound (21-75lb) Fuel surcharge
Zone2 $10.16 $1.5 $1.2 $14.77
Base rate (<=10lb) Rate per extra 5 pound (11-20lb) Rate per extra 10 pound (21-75lb) Fuel surcharge
Zone2 $11.62 $2.1 $2.9 $16.05
For example, for a package of 33 pounds, its shipping costs to three zones are listed below.
To Zone1: shippingCost = $9.25 + (33-10)*$0.17 + $11.01= $24.17
To Zone2: shippingCost = $10.16 + Math. ceil((33-10)/5))*$1.2 + $14.77 = $30.93
To Zone3: shippingCost = $11.62 + Math.ceil((33-10)/10))*$2.9 +$16.05 = $37.37
Your main job in this assignment is to implement a hierarchy of classes to represent the different types of service zones. At the top of the hierarchy, there is an abstract class ServiceZone whose derived classes are ServiceZone1, ServiceZone2, and ServiceZone3. They model the properties of the associated type of service zone as specified in ServiceZone.java, by defining the ServiceZone class's abstract methods.
Once you have defined these classes, you should complete the driver class A1.java. The driver class reads destination post codes and parcel weights from the standard input stream and output the shipping rates on the standard output stream.
The driver class also uses another class ZoneMap to find out the zone containing the input post code. You must fill out the missing definition in ZoneMap, i.e. the public ServiceZone getValidZone(String postCode) method that returns a ServiceZone1, ServiceZone2, or ServiceZone3 object depending on the zone containing postCode, or null if there is no zone containing postcode, assuming postcode is of three characters and weight is a positive integer. You must be able to handle postcode in upper or lower cases.
When executing the program, use java A1 zonePostcode.txt. When you have tested the program manually, try this on the command line:
java A1 zonePostcode.txt <testInput.txt > testOutput.txt
The file testOutput.txt should have only these three lines (EXACTLY)
The shipping cost is 24.17
The shipping cost is 36.37
The shipping cost is 30.93
I need help in writing a java program...
Based in Richmond Hill, ABC Courier Inc. provides next day delivery service of small parcels to GTA and surrounding areas for its customers in Richmond Hill. In this assignment, you will write a (much simplified) Java program to calculate their shipping rate of a single parcel.
To simplify the calculation of the shipping cost, ABC Courier has divided its service area into three zones based on their zip codes. This information can be found in zonePostcode.txt. The shipping cost consists of a base cost, a fuel surcharge and an extra cost beyond the free weight (10lb). Zones have different rates.
For single piece shipping, the rates are:
Base rate (<=10lb) Rate per extra pound (11-20lb) Rate per extra pound( 21-75lb) Fuel surcharge
Zone 1 $9.25 $0.18 $0.17 $11.01
Base rate (<=10lb) Rate per extra 5 pound (11-20lb) Rate per extra 5 pound (21-75lb) Fuel surcharge
Zone2 $10.16 $1.5 $1.2 $14.77
Base rate (<=10lb) Rate per extra 5 pound (11-20lb) Rate per extra 10 pound (21-75lb) Fuel surcharge
Zone2 $11.62 $2.1 $2.9 $16.05
For example, for a package of 33 pounds, its shipping costs to three zones are listed below.
To Zone1: shippingCost = $9.25 + (33-10)*$0.17 + $11.01= $24.17
To Zone2: shippingCost = $10.16 + Math. ceil((33-10)/5))*$1.2 + $14.77 = $30.93
To Zone3: shippingCost = $11.62 + Math.ceil((33-10)/10))*$2.9 +$16.05 = $37.37
Your main job in this assignment is to implement a hierarchy of classes to represent the different types of service zones. At the top of the hierarchy, there is an abstract class ServiceZone whose derived classes are ServiceZone1, ServiceZone2, and ServiceZone3. They model the properties of the associated type of service zone as specified in ServiceZone.java, by defining the ServiceZone class's abstract methods.
Once you have defined these classes, you should complete the driver class A1.java. The driver class reads destination post codes and parcel weights from the standard input stream and output the shipping rates on the standard output stream.
The driver class also uses another class ZoneMap to find out the zone containing the input post code. You must fill out the missing definition in ZoneMap, i.e. the public ServiceZone getValidZone(String postCode) method that returns a ServiceZone1, ServiceZone2, or ServiceZone3 object depending on the zone containing postCode, or null if there is no zone containing postcode, assuming postcode is of three characters and weight is a positive integer. You must be able to handle postcode in upper or lower cases.
When executing the program, use java A1 zonePostcode.txt. When you have tested the program manually, try this on the command line:
java A1 zonePostcode.txt <testInput.txt > testOutput.txt
The file testOutput.txt should have only these three lines (EXACTLY)
The shipping cost is 24.17
The shipping cost is 36.37
The shipping cost is 30.93