Question: Background write code in C Your company, A to Z Logistics, is in charge of packing shipping containers. Every container has two large compartments. The
Background write code in C
Your company, A to Z Logistics, is in charge of packing shipping containers. Every container has two large compartments. The items being shipped go evenly into the two compartments. Each item is encoded as a single character, az lowercase or AZ uppercase Your job is to write a program to calculate the shipping fees based on the items that go into the containers.
Specification
Your program will be provided, as input, one or more strings. Each container string contains only letters and it represents what's to be put into a container. A string that starts with a dot it will be the only character in the string will mark the end of input.
Here is a sample input, consisting of four container strings and the inputterminating string:
bmaBbZjRvs
PBZRiwlHcmbMRMUsTaCF
xpIJDqWoMniSOSFY
kLUsgJFedAkFfScuVRYxekDgsc
Because of limitations on container size, no string will be longer than characters.
Each letter corresponds to an item whose weight is determined by the table here:
Letter Weight
a kg
b kg
c kg
z kg
A kg
B kg
Z kg
In short, each successive letter represents an increase in weight of kg starting with kg for a up to kg for Z
Since the items in each container are split among the two compartments, the first half of the string represents the items in the one compartment and the second half are the items in the other compartment.
To calculate the billable weight, sum up the weights of the items in each compartment. Only the greater of the two weights will be used to calculate the shipping fee.
The shipping fee is billed at $ per kilogram.
When input has ended signified by the single dot on a line by itself the program displays the total shipping fee, displayed as a dollar amount with two decimal places.
Examples
For the container with items bmaBbZjRvs, one compartment gets items bmaBb and the other gets ZjRvs The sum of the weights for items bmaBb is kg; the sum of the weights for items ZjRvs is kg The greater of these two is kg The shipping fee is $ for each kg or $
For container PBZRiwlHcmbMRMUsTaCF, the two compartments are PBZRiwlHcm and bMRMUsTaCF, of which the second one is heavier. The shipping fee is $
For container xpIJDqWoMniSOSFY, the two compartments are xpIJDqWo and MniSOSFY. The shipping fee is $
Finally, for container kLUsgJFedAkFfScuVRYxekDgsc, the shipping fee is $
The total shipping fee for all four containers is $
Input and Output
The input to the program is the strings for all the containers, one per line.
Input is terminated by a string that contains only a single dot.
The program should display, at minimum:
The number of containers;
The total shipping fee.
For debugging purposes, it may display other information such as the weight and fee for each individual container. But the very last values displayed must the the number of containers and total shipping fee. This will make it easier for me to locate them.
Sample Run
Here is a sample of inputs and outputs. The user's input is shown in bold to make it stand out; your program will not need to do that.
Container: tRbCJqJdJbGwHzzChxFVfaSOnJJOBqPHimJq
Container: mQLDqEHRkl
Container: WAWweUUdGKUpfb
Container: TKHDdZENeCXMKCBzkPsULZPpduxzqpIeMSZMePPwQw
Container: KqdeyNvS
Container: enDEotyNOGBFjzZoguRtHC
Container:
containers, total shipping fee $
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
