CPSC 120 -- Assignment #1
Humanitarian Aid Shipment
Due Friday, September 23, 2011 by 4 p.m.
Write a Java program to help a humanitarian aid organization plan a
shipment of food to a country devastated by some natural disaster.
The organization wants
to send one shipping container of a single commodity (such as wheat, maize, or
dried milk). The interior of the
shipping container is 39.1 feet long by 7.5 feet wide by 7.7 feet high.
The commodity will be packaged in cylindrical drums which are different sizes
depending on what is being shipped. The shipping
company the organization plans to use charges $15.75 per drum plus
$3.50 per cubic foot for a filler material that is required to fill all
empty space in the container around the drums. The maximum total weight
of the commodity to be shipped (not counting the weight of
the drums or the weight of the filler) is 59,000 pounds.
The program should compute the number of drums that the organization can ship
(as described below)
and the total cost of shipping the container.
Input to the program will be:
- the dimensions (diameter and height) of a drum (in inches)
- the weight (in pounds) of one cubic foot of the commodity to be shipped
Output Your output must
be nicely formatted
and must include the following information (all
appropriately labeled):
- The maximum number of drums that will fit in a shipping container
- The maximum number of drums that can be shipped due to the weight limit
- The total number of drums to be shipped (the minimum of
the above two quantities)
- The number of cubic feet of the commodity that will be shipped
- The number of cubic feet of filler needed
- The total cost of the shipment
Assumptions: Your calculations should be based on the
following assumptions and requirements.
- Calculate the maximum number of drums that will fit in the container
using the following assumptions:
- The drums must be loaded upright in the container. That is,
the value entered as the height of a drum will determine how many
can be stacked up in the container.
- To figure out the maximum number of drums that will fit in
the container assume they will be loaded in a rectangular pattern along
the floor of the container. That is,
each row will have the same number of drums as will each column.
- It is possible that loading the maximum number of drums that fit
will exceed
the weight limit of the container so you must compute the maximum
number of drums that can be in the container based on weight. To do
this you need to do the following:
- Compute the weight of the commodity in each drum (remember that
you need to find the volume of a drum to do this).
- Then figure out how many drums can be shipped so the maximum
weight for the container is not exceeded.
- The number of drums that the organization can ship is the minimum
of the number that will fit in the container and the number
that can be shipped without exceeding the weight limit. There is a method
in the Math library that will find the minimum of two values for you.
- Once you have figured out how many drums will be shipped you need
to compute the number of cubic feet of space the drums will take up
and the number of cubic feet of extra space (not occupied by the drums).
- Finally compute the cost based on the number of drums and the
amount of filler needed for the extra space.
Sample Output (NOTE: This shows the prompts and input of
24 (inches) for the diameter
of the drum, 34.5 (inches) for the height of the drum, and
60 for the weight per cubic foot of the commodity)
Analysis of Shipment of Humanitarian Supplies
=============================================
Enter size of each drum to be shipped ---
diameter (in inches): 24
height (in inches): 34.5
Enter the weight (in pounds) per cubic foot of the commodity: 60
Shipment Summary
****************
Number of Drums That will Fit in the Container: 114
Maximum Number of Drums that can be shipped due to weight: 108
Number of Drums to Be Shipped: 108
Total Weight of the Shipment (in pounds): 58527.87...
Total Cubic Feet of Commodity Shipped: 975.4545...
Cubic Feet of Extra Space: 1282.560
Shipment Cost: $ 6189.96168...
NOTE: If you use the same size drum but a weight of 45 pounds per
cubic foot you get 114 drums to be shipped and a cost of $6094.788...
Requirements:
- You must use meaningful names for variables, constants, and
your class. Use Java conventions for case -- constants (declared
with final) are all uppercase (with the underscore separating words),
variables start with a lowercase letter (but each separate word
within the variable starts with a capital), the class name is
capitalized.
Choosing meaningful names makes your program easier to read and follow.
- You must use constant identifiers where appropriate (there are
several constants in the program).
- Use white space (blank lines and blank spaces) in your program to make
it easier to read. Separate the sections of the program with blank lines.
Indent and align your code properly (emacs helps you do this - it automatically
indents in most cases -- if a line isn't indented correctly go to it
and press TAB OR select the whole program using CTRL-x, CTRL-p then
use ALT-CTRL-\. If TAB doesn't make it indent correctly you probably have
a syntax error).
- Document your program. At the top you must have documentation that
includes the file name, a brief description of
what the program does (this MUST include a list of the input expected
and the output the program will produce), the date, and your name.
Use inline documentation to document each major section of code. However,
don't document every line!!
- See the following
code conventions for more detail about formatting
and documenting your program.
- Warning: A program that doesn't compile receives almost no credit
no matter how small the error.
- Optional (Extra Credit): Use the formatting objects from
Chapter 3 to format the numbers (especially the dollar amounts) so
they look better.
Submit to Inquire: A zip file containing your program.
Academic Integrity Reminder!!! Programming
assignments are to be your own work. You may get help on the specifics
of the assignment from no one except the instructor. You may not show
your program to anyone or look at anyone else's program or share ideas
with anyone about how to write the program.