Parcel Postage

Programming Quality Challenge #4

Problem Description

UPX postal service is a local California shipper.  Parcels shipped by UPX must adhere to the following constraints:
  1. Parcels are not to exceed a weight of 50 pounds.
  2. Parcels are not to exceed 3 feet in length, width, or depth.
  3. Parcel length plus parcel girth may not exceed 6  feet.  ( The girth of a packge is the circumference of the package around its two smallest sides: the mathematical formula is girth = 2 * (s1 + s2 + s3 - largest) where largest is the largest of the three parcel dimensions, s1, s2,  and s3.)
Your program should process a transaction file containing an unknown number of entries, one for each parcel mailed during the week.  Each entry contains a transaction number, followed by the weight of the box and its dimensions (the dimensions may be in any order), and a shipping zone code.  The program should print the transaction number, weight, zone code, and postal charge for all accepted packages. Transactions which are rejected cause the transaction number and an rejection message to be printed ("Weight too large" or "Size too large".)  At the end of the report, the program must print the number of packages processed successfully and the number rejected.
 

Input

Shipping Rate Table read from an external data file. (The name of this data file may be hard coded as a constant in your program.)
 
The first line of the data file consists of an arbitrary number of zone codes (each a 3 digit number).  Subsequent lines begin with a whole number representing a weight in pounds, followed by the cost in dollars to ship to each possible zone.  (Your program may assume the data file is properly formatted and contains valid data).

The postal cost of each parcel is determined by finding which row contains the weight and which column contains the zone code and then using the cost found at the intersection of the corresponding row and column in the table. If a package weight falls between weight categories in the table, your program should use the cost for the higher weight.


 
  101 102
1 5.50 7.75
10 20.25 27.00
25 31.50 37.75
50 49.00 52.25
For example, in the table above, a ten pound parcel going to zone 102 would cost $27, and a 40 pound parcel going to zone 101 would cost $49.


Transaction file - transaction number, weight (in pounds), three dimensions, and a zone code for an arbitrary number of transactions.  Assume all weights are whole numbers, and that all dimensions are given to the nearest inch (not feet).  Data fields are separated by one or more blanks.  The name of the transaction file is provided on the command line when the application is launched.
 

Sample Output

 
Transaction # Weight Zone Charge Rejection Message
39223 20 101 31.50
39227 9 102 27.00
39225 Weight too large.
39226 Size too large.
39229 17 102 37.75
3 packages accepted.
2 packages rejected.

 

Testing

Show execution output from running your program with this sample Shipping Rate Table. When you are ready to submit your work, ask the instructor for permission to read his test Transaction File and show an execution output using that file.