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 -
A text file consisting of one or more records. Each record contains a
transaction number, weight (in pounds),
three dimensions, and a zone code (in that order).
Assume all weights are positive 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
(C
or
Java)
when the application is launched.
An example transaction:
39233 15 4 8 12 101
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. |